Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmu fix MAIN/AUX parameters #9925

Merged
merged 3 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 30 additions & 12 deletions src/drivers/px4fmu/fmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,6 @@ PX4FMU::init()
/* initialize PWM limit lib */
pwm_limit_init(&_pwm_limit);

update_pwm_rev_mask();

#ifdef RC_SERIAL_PORT

# ifdef RF_RADIO_POWER_CONTROL
Expand All @@ -533,12 +531,6 @@ PX4FMU::init()
// Getting initial parameter values
update_params();

for (unsigned i = 0; i < _max_actuators; i++) {
char pname[16];
sprintf(pname, "PWM_AUX_TRIM%d", i + 1);
param_find(pname);
}

return 0;
}

Expand Down Expand Up @@ -922,15 +914,28 @@ PX4FMU::update_pwm_rev_mask()
{
_reverse_pwm_mask = 0;

const char *pname_format;

if (_class_instance == CLASS_DEVICE_PRIMARY) {
pname_format = "PWM_MAIN_REV%d";

} else if (_class_instance == CLASS_DEVICE_SECONDARY) {
pname_format = "PWM_AUX_REV%d";

} else {
PX4_ERR("PWM REV only for MAIN and AUX");
return;
}

for (unsigned i = 0; i < _max_actuators; i++) {
char pname[16];
int32_t ival;

/* fill the channel reverse mask from parameters */
sprintf(pname, "PWM_AUX_REV%d", i + 1);
sprintf(pname, pname_format, i + 1);
param_t param_h = param_find(pname);

if (param_h != PARAM_INVALID) {
int32_t ival = 0;
param_get(param_h, &ival);
_reverse_pwm_mask |= ((int16_t)(ival != 0)) << i;
}
Expand All @@ -946,15 +951,28 @@ PX4FMU::update_pwm_trims()

int16_t values[_max_actuators] = {};

const char *pname_format;

if (_class_instance == CLASS_DEVICE_PRIMARY) {
pname_format = "PWM_MAIN_TRIM%d";

} else if (_class_instance == CLASS_DEVICE_SECONDARY) {
pname_format = "PWM_AUX_TRIM%d";

} else {
PX4_ERR("PWM TRIM only for MAIN and AUX");
return;
}

for (unsigned i = 0; i < _max_actuators; i++) {
char pname[16];
float pval;

/* fill the struct from parameters */
sprintf(pname, "PWM_AUX_TRIM%d", i + 1);
sprintf(pname, pname_format, i + 1);
param_t param_h = param_find(pname);

if (param_h != PARAM_INVALID) {
float pval = 0.0f;
param_get(param_h, &pval);
values[i] = (int16_t)(10000 * pval);
PX4_DEBUG("%s: %d", pname, values[i]);
Expand Down
159 changes: 0 additions & 159 deletions src/drivers/px4fmu/px4fmu_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,165 +31,6 @@
*
****************************************************************************/

/**
* Invert direction of aux output channel 1
*
* Enable to invert the channel.
*
* @boolean
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV1, 0);

/**
* Invert direction of aux output channel 2
*
* Enable to invert the channel.
*
* @boolean
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV2, 0);

/**
* Invert direction of aux output channel 3
*
* Enable to invert the channel.
*
* @boolean
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV3, 0);

/**
* Invert direction of aux output channel 4
*
* Enable to invert the channel.
*
* @boolean
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV4, 0);

/**
* Invert direction of aux output channel 5
*
* Enable to invert the channel.
*
* @boolean
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV5, 0);

/**
* Invert direction of aux output channel 6
*
* Enable to invert the channel.
*
* @boolean
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV6, 0);

/**
* Trim value for FMU PWM output channel 1
*
* Set to normalized offset
*
* @min -0.2
* @max 0.2
* @decimal 2
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(PWM_AUX_TRIM1, 0);

/**
* Trim value for FMU PWM output channel 2
*
* Set to normalized offset
*
* @min -0.2
* @max 0.2
* @decimal 2
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(PWM_AUX_TRIM2, 0);

/**
* Trim value for FMU PWM output channel 3
*
* Set to normalized offset
*
* @min -0.2
* @max 0.2
* @decimal 2
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(PWM_AUX_TRIM3, 0);

/**
* Trim value for FMU PWM output channel 4
*
* Set to normalized offset
*
* @min -0.2
* @max 0.2
* @decimal 2
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(PWM_AUX_TRIM4, 0);

/**
* Trim value for FMU PWM output channel 5
*
* Set to normalized offset
*
* @min -0.2
* @max 0.2
* @decimal 2
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(PWM_AUX_TRIM5, 0);

/**
* Trim value for FMU PWM output channel 6
*
* Set to normalized offset
*
* @min -0.2
* @max 0.2
* @decimal 2
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(PWM_AUX_TRIM6, 0);

/**
* Thrust to PWM model parameter
*
* Parameter used to model the relationship between static thrust and motor
* input PWM. Model is: thrust = (1-factor)*PWM + factor * PWM^2
*
* @min 0.0
* @max 1.0
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(THR_MDL_FAC, 0.0f);

/**
* Minimum motor rise time (slew rate limit).
*
* Minimum time allowed for the motor input signal to pass through
* a range of 1000 PWM units. A value x means that the motor signal
* can only go from 1000 to 2000 PWM in maximum x seconds.
*
* Zero means that slew rate limiting is disabled.
*
* @min 0.0
* @unit s/(1000*PWM)
* @group PWM Outputs
*/
PARAM_DEFINE_FLOAT(MOT_SLEW_MAX, 0.0f);

/**
* Motor Ordering
*
Expand Down
Loading