RPM sensor based on time difference between pulses
It uses an PWM input to measure the period between pulses.
Example for airframe file
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="rpm_sensor">
b'<define name="RPM_PULSE_PER_RND" value="14" />\n '
b'<define name="RPM_FILTER_TAU" value="0.3" />\n '
b'<define name="RPM_SENSOR_ACTUATOR_IDX" value="" />\n '
b'<configure name="RPM_PWM_CHANNEL" value="PWM_INPUTX" />\n '
</module>
Module configuration options
Configure Options
- name:
RPM_PWM_CHANNEL
value: PWM_INPUTX
Description: Select PWM input channel for RPM sensor
Define Options
- name:
RPM_PULSE_PER_RND
value: 14
Description: Amount of pulses per round
- name:
RPM_FILTER_TAU
value: 0.3
Description: 1/cut-off-frequency = filter time
- name:
RPM_SENSOR_ACTUATOR_IDX
value:
Description: the actuator which we are sensing the RPM for
Module functions
Init Functions
These initialization functions are called once on startup.
Periodic Functions
These functions are called periodically at the specified frequency from the module periodic loop.
- rpm_sensor_periodic()
- Running at maximum module frequency.
- Autorun: TRUE
Periodic function automatically starts after init.
Files
Header Files
The following headers are automatically included in modules.h
Source Files
Raw rpm_sensor.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="rpm_sensor" dir="sensors">
<doc>
<description>RPM sensor based on time difference between pulses
It uses an PWM input to measure the period between pulses.
</description>
<configure name="RPM_PWM_CHANNEL" value="PWM_INPUTX" description="Select PWM input channel for RPM sensor"/>
<define name="RPM_PULSE_PER_RND" value="14" description="Amount of pulses per round"/>
<define name="RPM_FILTER_TAU" value="0.3" description="1/cut-off-frequency = filter time"/>
<define name="RPM_SENSOR_ACTUATOR_IDX" value="" description="the actuator which we are sensing the RPM for"/>
</doc>
<dep>
<depends>pwm_meas</depends>
</dep>
<header>
<file name="rpm_sensor.h"/>
</header>
<init fun="rpm_sensor_init()"/>
<periodic fun="rpm_sensor_periodic()" autorun="TRUE"/>
<makefile>
<file name="rpm_sensor.c"/>
<configure name="RPM_PWM_CHANNEL" default="PWM_INPUT1"/>
<define name="RPM_PWM_CHANNEL" value="$(RPM_PWM_CHANNEL)"/>
<define name="$(RPM_PWM_CHANNEL)_TICKS_PER_USEC" value="1" />
<define name="USE_$(RPM_PWM_CHANNEL)" value="PWM_PULSE_TYPE_ACTIVE_HIGH" />
</makefile>
</module>