mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
change main trims to normalized values
This commit is contained in:
parent
dbc149c224
commit
f0b41a0e52
@ -25,7 +25,7 @@ class XMLOutput():
|
||||
xml_version = ET.SubElement(xml_parameters, "parameter_version_major")
|
||||
xml_version.text = "1"
|
||||
xml_version = ET.SubElement(xml_parameters, "parameter_version_minor")
|
||||
xml_version.text = "12"
|
||||
xml_version.text = "13"
|
||||
importtree = ET.parse(inject_xml_file_name)
|
||||
injectgroups = importtree.getroot().findall("group")
|
||||
for igroup in injectgroups:
|
||||
|
||||
@ -111,7 +111,7 @@ PARAM_DEFINE_INT32(PWM_AUX_REV6, 0);
|
||||
/**
|
||||
* Trim value for FMU PWM output channel 1
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
@ -123,7 +123,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM1, 0);
|
||||
/**
|
||||
* Trim value for FMU PWM output channel 2
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
@ -135,7 +135,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM2, 0);
|
||||
/**
|
||||
* Trim value for FMU PWM output channel 3
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
@ -147,7 +147,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM3, 0);
|
||||
/**
|
||||
* Trim value for FMU PWM output channel 4
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
@ -159,7 +159,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM4, 0);
|
||||
/**
|
||||
* Trim value for FMU PWM output channel 5
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
@ -171,7 +171,7 @@ PARAM_DEFINE_FLOAT(PWM_AUX_TRIM5, 0);
|
||||
/**
|
||||
* Trim value for FMU PWM output channel 6
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
|
||||
@ -1207,12 +1207,12 @@ PX4IO::task_main()
|
||||
// update trim values
|
||||
struct pwm_output_values 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);
|
||||
// memset(&pwm_values, 0, sizeof(pwm_values));
|
||||
// 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++) {
|
||||
char pname[16];
|
||||
int32_t ival;
|
||||
float pval;
|
||||
|
||||
/* fetch the trim values from parameters */
|
||||
sprintf(pname, "PWM_MAIN_TRIM%u", i + 1);
|
||||
@ -1220,8 +1220,8 @@ PX4IO::task_main()
|
||||
|
||||
if (param_h != PARAM_INVALID) {
|
||||
|
||||
param_get(param_h, &ival);
|
||||
pwm_values.values[i] = ival;
|
||||
param_get(param_h, &pval);
|
||||
pwm_values.values[i] = (int16_t)(10000 * pval);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -133,90 +133,98 @@ PARAM_DEFINE_INT32(PWM_MAIN_REV8, 0);
|
||||
/**
|
||||
* Trim value for main output channel 1
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM1, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM1, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 2
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM2, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM2, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 3
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM3, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM3, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 4
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM4, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM4, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 5
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM5, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM5, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 6
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM6, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM6, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 7
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM7, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM7, 0);
|
||||
|
||||
/**
|
||||
* Trim value for main output channel 8
|
||||
*
|
||||
* Set to neutral period in usec
|
||||
* Set to normalized offset
|
||||
*
|
||||
* @min 1400
|
||||
* @max 1600
|
||||
* @min -0.2
|
||||
* @max 0.2
|
||||
* @decimal 2
|
||||
* @group PWM Outputs
|
||||
*/
|
||||
PARAM_DEFINE_INT32(PWM_MAIN_TRIM8, 1500);
|
||||
PARAM_DEFINE_FLOAT(PWM_MAIN_TRIM8, 0);
|
||||
|
||||
/**
|
||||
* S.BUS out
|
||||
|
||||
@ -399,19 +399,19 @@ registers_set(uint8_t page, uint8_t offset, const uint16_t *values, unsigned num
|
||||
/* copy channel data */
|
||||
while ((offset < PX4IO_SERVO_COUNT) && (num_values > 0)) {
|
||||
|
||||
if (*values == 0) {
|
||||
/* allow 0 - turns the trim option off */
|
||||
r_page_servo_control_trim[offset] = 0;
|
||||
|
||||
} else if (*values > PWM_HIGHEST_MAX) {
|
||||
r_page_servo_control_trim[offset] = PWM_HIGHEST_MAX;
|
||||
|
||||
} else if (*values < PWM_LOWEST_MAX) {
|
||||
r_page_servo_control_trim[offset] = PWM_LOWEST_MAX;
|
||||
|
||||
} else {
|
||||
r_page_servo_control_trim[offset] = *values;
|
||||
}
|
||||
// if (*values == 0) {
|
||||
// /* allow 0 - turns the trim option off */
|
||||
// r_page_servo_control_trim[offset] = 0;
|
||||
//
|
||||
// } else if (*values > PWM_HIGHEST_MAX) {
|
||||
// r_page_servo_control_trim[offset] = PWM_HIGHEST_MAX;
|
||||
//
|
||||
// } else if (*values < PWM_LOWEST_MAX) {
|
||||
// r_page_servo_control_trim[offset] = PWM_LOWEST_MAX;
|
||||
//
|
||||
// } else {
|
||||
r_page_servo_control_trim[offset] = *values;
|
||||
// }
|
||||
|
||||
offset++;
|
||||
num_values--;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user