Remove duplicite data from RPM message and enable logging of RPM message

This commit is contained in:
Roman Dvořák 2020-03-30 19:08:53 +02:00 committed by GitHub
parent 536cd6cb1a
commit b02e209507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 16 deletions

View File

@ -1,7 +1,4 @@
uint64 timestamp # time since system start (microseconds) 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 indicated_frequency_rpm # indicated rotor Frequency in Revolution per minute
float32 estimated_accurancy_rpm # estimated accurancy in Revolution per minute float32 estimated_accurancy_rpm # estimated accurancy in Revolution per minute

View File

@ -127,15 +127,13 @@ void PCF8583::RunImpl()
_count = 0; _count = 0;
} }
float indicated_frequency = (float)diffCount / _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); float estimated_accurancy = 1 / (float)_param_pcf8583_magnet.get() / ((float)diffTime / 1000000) * 60.f;
// publish // publish
rpm_s msg{}; rpm_s msg{};
msg.indicated_frequency_hz = indicated_frequency; msg.indicated_frequency_rpm = indicated_rpm;
msg.indicated_frequency_rpm = indicated_frequency * 60.f; msg.estimated_accurancy_rpm = estimated_accurancy;
msg.estimated_accurancy_hz = estimated_accurancy;
msg.estimated_accurancy_rpm = estimated_accurancy * 60.f;
msg.timestamp = hrt_absolute_time(); msg.timestamp = hrt_absolute_time();
_rpm_pub.publish(msg); _rpm_pub.publish(msg);
} }

View File

@ -33,6 +33,7 @@
/** /**
* PCF8583 rotorfreq (i2c) pool interval * PCF8583 rotorfreq (i2c) pool interval
* How often the sensor is readout.
* *
* @reboot_required true * @reboot_required true
* @group Sensors * @group Sensors
@ -45,30 +46,31 @@ PARAM_DEFINE_INT32(PCF8583_POOL, 1000000);
* *
* @reboot_required true * @reboot_required true
* @group Sensors * @group Sensors
* @value 80 0x50 * @value 80 Address 0x50 (80)
* @value 81 0x51 * @value 81 Address 0x51 (81)
*/ */
PARAM_DEFINE_INT32(PCF8583_ADDR, 80); 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, * Internal device counter is reset to 0 when overun this value,
* counter is able to store upto 6 digits * 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 * @reboot_required true
* @group Sensors * @group Sensors
* @value 0 - reset avter every measurement
*/ */
PARAM_DEFINE_INT32(PCF8583_RESET, 500000); 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 * @reboot_required true
* @group Sensors
* @min 1 * @min 1
*/ */
PARAM_DEFINE_INT32(PCF8583_MAGNET, 2); PARAM_DEFINE_INT32(PCF8583_MAGNET, 2);