With the External Control, the MK can be controlled via serial commands. see also: [[en/SerialProtocol|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) * CareFree * Autostart & Autoland * AltitudeHold {i} these functions are only active, if the bit "EC_USE_SWITCH" is set in the ExternalControl .Config {i} 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 == {{ http://gallery3.mikrokopter.de/var/albums/tech/ExternalControl1.gif?m=1445852070 }} 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 == {{ http://gallery3.mikrokopter.de/var/albums/tech/ExternalControl2.gif?m=1445852077 }} 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 == {{{ #!cplusplus #define EC_VALID 0x01 // only valid if this is 1 #define EC_GAS_ADD 0x02 // if 1 -> use the GAS Value directly and not as MAX #define EC_USE_SWITCH 0x20 // if 1 -> use the Switches for further control -> the according RC transmitter switches are deactivated #define EC_IGNORE_RC_STICK 0x40 // direct control (do not add to RC-Sticks Nick, Roll, Yaw) #define EC_IGNORE_RC_LOST 0x80 // if 1 -> for Flying without RC-Control (Ignore RC-Lost) }}} == defines for ExternalControl.Switches == * control GPS Modes etc. * only active if this bit is set: EC_USE_SWITCH in Config {{{ #!cplusplus #define EC2_PH 0x01 // GPS-Mode: PH #define EC2_CH 0x02 // GPS-Mode: CH #define EC2_CAREFREE 0x10 // CareFree on #define EC2_ALTITUDE 0x20 // Altitude Hold: on #define EC2_AUTOSTART 0x40 // Activates Autotstart #define EC2_AUTOLAND 0x80 // Activates Autolanding }}} == Structure == {{{ #!cplusplus struct str_ExternControl { signed char Nick; signed char Roll; signed char Gier; signed char Gas; unsigned char Frame; // will return a confirm frame with this value unsigned char Config; unsigned char Switches; unsigned char Free1; // these two don't need capacity in the ASCII data string unsigned char Free2; }; 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. {{{ #!cplusplus if((CheckDelay(EC_Timer)) && UebertragungAbgeschlossen) { static struct str_ExternControl Test; Test.Nick = ChannelNick; Test.Roll = ChannelRoll; Test.Gier = ChannelYaw; Test.Gas = ChannelGas; Test.Frame++; Test.Config = 0; if(PPM_in[16] > 64) Test.Config |= EC_GAS_ADD | EC_USE_SWITCH | EC_VALID; if(PPM_in[13] > 64) Test.Config |= EC_IGNORE_RC | EC_IGNORE_RC_STICK; Test.Switches = 0; if(PPM_in[5] > 64) Test.Switches |= EC2_ALTITUDE; if(PPM_in[6] > 64) Test.Switches |= EC2_CH; else if(PPM_in[6] > -64)Test.Switches |= EC2_PH; if(PPM_in[8] > 64) Test.Switches |= EC2_CAREFREE; if(PPM_in[10] > 64) Test.Switches |= EC2_AUTOSTART; if(PPM_in[10] < -64) Test.Switches |= EC2_AUTOLAND; SendOutData('b', FC_ADDRESS, 1, (unsigned char *) &Test,sizeof(Test)); EC_Timer = SetDelay(50); } }}}