mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 15:38:52 +08:00
RPMCapture: fix pulses per revolution parameter name, description, type -> use module params
This commit is contained in:
@@ -40,7 +40,8 @@
|
||||
#include <systemlib/mavlink_log.h>
|
||||
|
||||
RPMCapture::RPMCapture() :
|
||||
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default)
|
||||
ScheduledWorkItem(MODULE_NAME, px4::wq_configurations::hp_default),
|
||||
ModuleParams(nullptr)
|
||||
{
|
||||
_pwm_input_pub.advertise();
|
||||
ScheduleNow();
|
||||
@@ -58,8 +59,8 @@ bool RPMCapture::init()
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
param_get(param_find("RPM_PULSES_PER_REV"), &_pulses_per_revolution);
|
||||
_min_pulse_period_us = static_cast<uint32_t>(60.f * 1e6f / static_cast<float>(RPM_MAX_VALUE * _pulses_per_revolution));
|
||||
_min_pulse_period_us = static_cast<uint32_t>(60.f * 1e6f / static_cast<float>(RPM_MAX_VALUE *
|
||||
_param_rpm_puls_per_rev.get()));
|
||||
|
||||
for (unsigned i = 0; i < 16; ++i) {
|
||||
char param_name[17];
|
||||
@@ -135,7 +136,7 @@ void RPMCapture::Run()
|
||||
|
||||
if (_period < RPM_PULSE_TIMEOUT) {
|
||||
// 1'000'000 / [us] -> pulses per second * 60 -> pulses per minute
|
||||
rpm_raw = 60.f * 1e6f / static_cast<float>(_pulses_per_revolution * _period);
|
||||
rpm_raw = 60.f * 1e6f / static_cast<float>(_param_rpm_puls_per_rev.get() * _period);
|
||||
}
|
||||
|
||||
const float dt = math::constrain((now - _timestamp_last_update) * 1e-6f, 0.01f, 1.f);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <lib/mathlib/math/filter/MedianFilter.hpp>
|
||||
#include <px4_arch/micro_hal.h>
|
||||
#include <px4_platform_common/module.h>
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
|
||||
#include <uORB/Publication.hpp>
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
@@ -46,7 +47,7 @@
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
class RPMCapture : public ModuleBase<RPMCapture>, public px4::ScheduledWorkItem
|
||||
class RPMCapture : public ModuleBase<RPMCapture>, public px4::ScheduledWorkItem, public ModuleParams
|
||||
{
|
||||
public:
|
||||
RPMCapture();
|
||||
@@ -76,7 +77,6 @@ private:
|
||||
|
||||
int _channel{-1};
|
||||
uint32_t _rpm_capture_gpio{0};
|
||||
uint32_t _pulses_per_revolution{1};
|
||||
uint32_t _min_pulse_period_us{1}; ///< [us] minimum pulse period
|
||||
uORB::Publication<pwm_input_s> _pwm_input_pub{ORB_ID(pwm_input)};
|
||||
uORB::PublicationMulti<rpm_s> _rpm_pub{ORB_ID(rpm)};
|
||||
@@ -90,4 +90,8 @@ private:
|
||||
hrt_abstime _timestamp_last_update{0}; ///< to caluclate dt
|
||||
AlphaFilter<float> _rpm_filter;
|
||||
MedianFilter<float, 5> _rpm_median_filter;
|
||||
|
||||
DEFINE_PARAMETERS(
|
||||
(ParamInt<px4::params::RPM_PULS_PER_REV>) _param_rpm_puls_per_rev
|
||||
)
|
||||
};
|
||||
|
||||
@@ -43,13 +43,13 @@
|
||||
PARAM_DEFINE_INT32(RPM_CAP_ENABLE, 0);
|
||||
|
||||
/**
|
||||
* RPM Pulses per Revolution
|
||||
* Voltage pulses per revolution
|
||||
*
|
||||
* Number of pulses per revolution for the RPM sensor.
|
||||
* Number of voltage pulses per one rotor revolution on the capturing pin.
|
||||
*
|
||||
* @group System
|
||||
* @min 1
|
||||
* @max 50
|
||||
* @reboot_required true
|
||||
*/
|
||||
PARAM_DEFINE_INT32(RPM_PULSES_PER_REV, 1);
|
||||
PARAM_DEFINE_INT32(RPM_PULS_PER_REV, 1);
|
||||
|
||||
Reference in New Issue
Block a user