From b02e20950795c0b9653900827bf81d8513f3be36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Dvo=C5=99=C3=A1k?= Date: Mon, 30 Mar 2020 19:08:53 +0200 Subject: [PATCH] Remove duplicite data from RPM message and enable logging of RPM message --- msg/rpm.msg | 3 --- src/drivers/rpm/pcf8583/PCF8583.cpp | 10 ++++------ src/drivers/rpm/pcf8583/parameters.c | 16 +++++++++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/msg/rpm.msg b/msg/rpm.msg index 53b9010066..9ddb7d92f2 100644 --- a/msg/rpm.msg +++ b/msg/rpm.msg @@ -1,7 +1,4 @@ uint64 timestamp # time since system start (microseconds) -float32 indicated_frequency_hz # indicated rotor Frequency in Hz -float32 estimated_accurancy_hz # estimated accurancy in Hz float32 indicated_frequency_rpm # indicated rotor Frequency in Revolution per minute float32 estimated_accurancy_rpm # estimated accurancy in Revolution per minute - diff --git a/src/drivers/rpm/pcf8583/PCF8583.cpp b/src/drivers/rpm/pcf8583/PCF8583.cpp index c7765bac7f..5a28978db6 100644 --- a/src/drivers/rpm/pcf8583/PCF8583.cpp +++ b/src/drivers/rpm/pcf8583/PCF8583.cpp @@ -127,15 +127,13 @@ void PCF8583::RunImpl() _count = 0; } - float indicated_frequency = (float)diffCount / _param_pcf8583_magnet.get() / ((float)diffTime / 1000000); - float estimated_accurancy = 1 / (float)_param_pcf8583_magnet.get() / ((float)diffTime / 1000000); + float indicated_rpm = (float)diffCount / _param_pcf8583_magnet.get() / ((float)diffTime / 1000000) * 60.f; + float estimated_accurancy = 1 / (float)_param_pcf8583_magnet.get() / ((float)diffTime / 1000000) * 60.f; // publish rpm_s msg{}; - msg.indicated_frequency_hz = indicated_frequency; - msg.indicated_frequency_rpm = indicated_frequency * 60.f; - msg.estimated_accurancy_hz = estimated_accurancy; - msg.estimated_accurancy_rpm = estimated_accurancy * 60.f; + msg.indicated_frequency_rpm = indicated_rpm; + msg.estimated_accurancy_rpm = estimated_accurancy; msg.timestamp = hrt_absolute_time(); _rpm_pub.publish(msg); } diff --git a/src/drivers/rpm/pcf8583/parameters.c b/src/drivers/rpm/pcf8583/parameters.c index 58c1becc91..b1d7ff779f 100644 --- a/src/drivers/rpm/pcf8583/parameters.c +++ b/src/drivers/rpm/pcf8583/parameters.c @@ -33,6 +33,7 @@ /** * PCF8583 rotorfreq (i2c) pool interval + * How often the sensor is readout. * * @reboot_required true * @group Sensors @@ -45,30 +46,31 @@ PARAM_DEFINE_INT32(PCF8583_POOL, 1000000); * * @reboot_required true * @group Sensors - * @value 80 0x50 - * @value 81 0x51 + * @value 80 Address 0x50 (80) + * @value 81 Address 0x51 (81) */ PARAM_DEFINE_INT32(PCF8583_ADDR, 80); /** - * PCF8583 rotorfreq (i2c) counter reset value + * PCF8583 rotorfreq (i2c) pulse reset value * * Internal device counter is reset to 0 when overun this value, * counter is able to store upto 6 digits - * reset of counter takes some time - measurement with reset has worse accurancy + * reset of counter takes some time - measurement with reset has worse accurancy. + * 0 means reset counter after every measurement. * * @reboot_required true * @group Sensors - * @value 0 - reset avter every measurement */ PARAM_DEFINE_INT32(PCF8583_RESET, 500000); /** - * PCF8583 rotorfreq (i2c) magnet count + * PCF8583 rotorfreq (i2c) pulse count * - * Nmumber of signals per rotation of rotor + * Nmumber of signals per rotation of actuator * * @reboot_required true + * @group Sensors * @min 1 */ PARAM_DEFINE_INT32(PCF8583_MAGNET, 2);