How to use:
To get an individual set of defaults I save a working set of values via gui into a copter.mwi file.
Then use a converter to turn this into some c-code.
If needed, manually edit that c-code to suit your taste.
compile and upload
every reset only resets to a known good starting point for this copter
advantage:
have proven copter specific good starting point of defaults for this copter in the firmware, available at touch of 'reset'.
If tuning pids goes wrong, simply press reset and start all over with a proven set of good defaults for your copter.
The modified code to easily use that snippet from config.h without editing eeprom.cpp will follow soon.
Some code to invoke reset via the lcd.config menu will follow soon.
Here is the converter script;
Code: Select all
#!/usr/bin/perl -w
#
# mwii2c_defaults_converter
# converts a single .mwi file (as generated by doing a save in the MWii Config GUI) to the corresponding c code fragment.
# Purpose is to replace the hard coded defaults in eeprom.cpp with a tailored set of defaults that have somehow proven to
# be a better starting point for future tuning than the universally supplied ones.
#
# Usage:
# mwii2c_defaults_converter < your.mwi > your.c
# this will read your.mwi file andwrite the c-code section to your.c file
#
# v0.1
# - initial version
#
$\ = "\n";
$t = localtime(time());
print "/* autogenerated $t */";
while (<>) {
if (m#<entry +key=\"(.*)\">(.*)</entry>#) {
$k = $1;
$v = $2;
#print "$k = $v";
print "conf.pid[ROLL].P8 = ", 10*$v,';' if ($k eq "pid.0.p");
print "conf.pid[ROLL].I8 = ", 1000*$v,';' if ($k eq "pid.0.i");
print "conf.pid[ROLL].D8 = ", 1*$v,';' if ($k eq "pid.0.d");
print "conf.pid[PITCH].P8 = ", 10*$v,';' if ($k eq "pid.1.p");
print "conf.pid[PITCH].I8 = ", 1000*$v,';' if ($k eq "pid.1.i");
print "conf.pid[PITCH].D8 = ", 1*$v,';' if ($k eq "pid.1.d");
print "conf.pid[YAW].P8 = ", 10*$v,';' if ($k eq "pid.2.p");
print "conf.pid[YAW].I8 = ", 1000*$v,';' if ($k eq "pid.2.i");
print "conf.pid[YAW].D8 = ", 1*$v,';' if ($k eq "pid.2.d");
print "conf.pid[PIDALT].P8 = ", 10*$v,';' if ($k eq "pid.3.p");
print "conf.pid[PIDALT].I8 = ", 1000*$v,';' if ($k eq "pid.3.i");
print "conf.pid[PIDALT].D8 = ", 1*$v,';' if ($k eq "pid.3.d");
print "conf.pid[PIDPOS].P8 = ", 100*$v,';' if ($k eq "pid.4.p");
print "conf.pid[PIDPOS].I8 = ", 1000*$v,';' if ($k eq "pid.4.i");
print "conf.pid[PIDPOS].D8 = ", 1*$v,';' if ($k eq "pid.4.d");
print "conf.pid[PIDPOSR].P8 = ", 10*$v,';' if ($k eq "pid.5.p");
print "conf.pid[PIDPOSR].I8 = ", 1000*$v,';' if ($k eq "pid.5.i");
print "conf.pid[PIDPOSR].D8 = ", 1000*$v,';' if ($k eq "pid.5.d");
print "conf.pid[PIDNAVR].P8 = ", 10*$v,';' if ($k eq "pid.6.p");
print "conf.pid[PIDNAVR].I8 = ", 1000*$v,';' if ($k eq "pid.6.i");
print "conf.pid[PIDNAVR].D8 = ", 100*$v,';' if ($k eq "pid.6.d");
print "conf.pid[PIDLEVEL].P8 = ", 10*$v,';' if ($k eq "pid.7.p");
print "conf.pid[PIDLEVEL].I8 = ", 1000*$v,';' if ($k eq "pid.7.i");
print "conf.pid[PIDLEVEL].D8 = ", 1*$v,';' if ($k eq "pid.7.d");
print "conf.pid[PIDMAG].P8 = ", 10*$v,';' if ($k eq "pid.8.p");
#print "conf.pid[PIDMAG].I8 = ", 1000*$v,';' if ($k eq "pid.8.i");
#print "conf.pid[PIDMAG].D8 = ", 1*$v,';' if ($k eq "pid.8.d");
print "conf.pid[PIDVEL].P8 = ", 10*$v,';' if ($k eq "pid.9.p");
print "conf.pid[PIDVEL].I8 = ", 1000*$v,';' if ($k eq "pid.9.i");
print "conf.pid[PIDVEL].D8 = ", 1*$v,';' if ($k eq "pid.9.d");
print "conf.powerTrigger1 = ", 1*$v,';' if ($k eq "power.trigger");
print "conf.rcExpo8 = " , 100*$v,';' if ($k eq "rc.expo");
print "conf.rcRate8 = ", 100*$v,';' if ($k eq "rc.rate");
print "conf.rollPitchRate = ", 100*$v,';' if ($k eq "rc.rollpitch.rate");
print "conf.thrExpo8 = ", 100*$v,';' if ($k eq "rc.throttle.expo");
print "conf.thrMid8 = ", 100*$v,';' if ($k eq "rc.throttle.mid");
print "conf.dynThrPID = ", 100*$v,';' if ($k eq "rc.throttle.rate");
print "conf.yawRate = ", 100*$v,';' if ($k eq "rc.yaw.rate");
}
}
print "\n";
print "
for(i=0;i<CHECKBOXITEMS;i++) {conf.activate[i] = 0;}
conf.angleTrim[0] = 0; conf.angleTrim[1] = 0;
";