change main trims to normalized values

This commit is contained in:
Mark Whitehorn
2016-11-09 15:05:30 -07:00
committed by Lorenz Meier
parent dbc149c224
commit f0b41a0e52
5 changed files with 65 additions and 57 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ class XMLOutput():
xml_version = ET.SubElement(xml_parameters, "parameter_version_major") xml_version = ET.SubElement(xml_parameters, "parameter_version_major")
xml_version.text = "1" xml_version.text = "1"
xml_version = ET.SubElement(xml_parameters, "parameter_version_minor") xml_version = ET.SubElement(xml_parameters, "parameter_version_minor")
xml_version.text = "12" xml_version.text = "13"
importtree = ET.parse(inject_xml_file_name) importtree = ET.parse(inject_xml_file_name)
injectgroups = importtree.getroot().findall("group") injectgroups = importtree.getroot().findall("group")
for igroup in injectgroups: for igroup in injectgroups:
+6 -6
View File
@@ -111,7 +111,7 @@ PARAM_DEFINE_INT32(PWM_AUX_REV6, 0);
/** /**
* Trim value for FMU PWM output channel 1 * Trim value for FMU PWM output channel 1
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min -0.2 * @min -0.2
* @max 0.2 * @max 0.2
@@ -123,7 +123,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM1, 0);
/** /**
* Trim value for FMU PWM output channel 2 * Trim value for FMU PWM output channel 2
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min -0.2 * @min -0.2
* @max 0.2 * @max 0.2
@@ -135,7 +135,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM2, 0);
/** /**
* Trim value for FMU PWM output channel 3 * Trim value for FMU PWM output channel 3
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min -0.2 * @min -0.2
* @max 0.2 * @max 0.2
@@ -147,7 +147,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM3, 0);
/** /**
* Trim value for FMU PWM output channel 4 * Trim value for FMU PWM output channel 4
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min -0.2 * @min -0.2
* @max 0.2 * @max 0.2
@@ -159,7 +159,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM4, 0);
/** /**
* Trim value for FMU PWM output channel 5 * Trim value for FMU PWM output channel 5
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min -0.2 * @min -0.2
* @max 0.2 * @max 0.2
@@ -171,7 +171,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM5, 0);
/** /**
* Trim value for FMU PWM output channel 6 * Trim value for FMU PWM output channel 6
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min -0.2 * @min -0.2
* @max 0.2 * @max 0.2
+5 -5
View File
@@ -1207,12 +1207,12 @@ PX4IO::task_main()
// update trim values // update trim values
struct pwm_output_values pwm_values; struct pwm_output_values pwm_values;
memset(&pwm_values, 0, sizeof(pwm_values)); // memset(&pwm_values, 0, sizeof(pwm_values));
ret = io_reg_get(PX4IO_PAGE_CONTROL_TRIM_PWM, 0, (uint16_t *)pwm_values.values, _max_actuators); // ret = io_reg_get(PX4IO_PAGE_CONTROL_TRIM_PWM, 0, (uint16_t *)pwm_values.values, _max_actuators);
for (unsigned i = 0; i < _max_actuators; i++) { for (unsigned i = 0; i < _max_actuators; i++) {
char pname[16]; char pname[16];
int32_t ival; float pval;
/* fetch the trim values from parameters */ /* fetch the trim values from parameters */
sprintf(pname, "PWM_MAIN_TRIM%u", i + 1); sprintf(pname, "PWM_MAIN_TRIM%u", i + 1);
@@ -1220,8 +1220,8 @@ PX4IO::task_main()
if (param_h != PARAM_INVALID) { if (param_h != PARAM_INVALID) {
param_get(param_h, &ival); param_get(param_h, &pval);
pwm_values.values[i] = ival; pwm_values.values[i] = (int16_t)(10000 * pval);
} }
} }
+40 -32
View File
@@ -133,90 +133,98 @@ PARAM_DEFINE_INT32(PWM_MAIN_REV8, 0);
/** /**
* Trim value for main output channel 1 * Trim value for main output channel 1
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM1, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM1, 0);
/** /**
* Trim value for main output channel 2 * Trim value for main output channel 2
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM2, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM2, 0);
/** /**
* Trim value for main output channel 3 * Trim value for main output channel 3
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM3, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM3, 0);
/** /**
* Trim value for main output channel 4 * Trim value for main output channel 4
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM4, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM4, 0);
/** /**
* Trim value for main output channel 5 * Trim value for main output channel 5
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM5, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM5, 0);
/** /**
* Trim value for main output channel 6 * Trim value for main output channel 6
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM6, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM6, 0);
/** /**
* Trim value for main output channel 7 * Trim value for main output channel 7
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM7, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM7, 0);
/** /**
* Trim value for main output channel 8 * Trim value for main output channel 8
* *
* Set to neutral period in usec * Set to normalized offset
* *
* @min 1400 * @min -0.2
* @max 1600 * @max 0.2
* @decimal 2
* @group PWM Outputs * @group PWM Outputs
*/ */
PARAM_DEFINE_INT32(PWM_MAIN_TRIM8, 1500); PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM8, 0);
/** /**
* S.BUS out * S.BUS out
+13 -13
View File
@@ -399,19 +399,19 @@ registers_set(uint8_t page, uint8_t offset, const uint16_t *values, unsigned num
/* copy channel data */ /* copy channel data */
while ((offset < PX4IO_SERVO_COUNT) && (num_values > 0)) { while ((offset < PX4IO_SERVO_COUNT) && (num_values > 0)) {
if (*values == 0) { // if (*values == 0) {
/* allow 0 - turns the trim option off */ // /* allow 0 - turns the trim option off */
r_page_servo_control_trim[offset] = 0; // r_page_servo_control_trim[offset] = 0;
//
} else if (*values > PWM_HIGHEST_MAX) { // } else if (*values > PWM_HIGHEST_MAX) {
r_page_servo_control_trim[offset] = PWM_HIGHEST_MAX; // r_page_servo_control_trim[offset] = PWM_HIGHEST_MAX;
//
} else if (*values < PWM_LOWEST_MAX) { // } else if (*values < PWM_LOWEST_MAX) {
r_page_servo_control_trim[offset] = PWM_LOWEST_MAX; // r_page_servo_control_trim[offset] = PWM_LOWEST_MAX;
//
} else { // } else {
r_page_servo_control_trim[offset] = *values; r_page_servo_control_trim[offset] = *values;
} // }
offset++; offset++;
num_values--; num_values--;