Using a very basic RPM sensor can I measure RPM in pixhawk ? The rpm sensor works digitally ( high and low states ) , can I use pixhawk Aux pins to read the pulses and use a counter to increment ?
Searched on the google forums and found that Lorenz suggested that can be done using the pwm_input.cpp in the drives. (https://github.com/PX4/Firmware/blob/master/src/drivers/pwm_input/pwm_input.cpp). But just cant figure out which pins and how to move forward
Any help would be grateful
Yes you can definitely do this. What’s the sensor?
You’ll need to write a little driver to read the data, and then publish an ESC status message. This will be logged automatically.
Thanks man…currently I’m using pwm_input.cpp ( driver code ) and I can find the rpm using the pulse time period. I can connect my sensor to AUX Pin 5 and using the variation in pulse duration I can calculate the propeller rpm.
For this currently I’m using pwm_input test command from the terminal. But this code doesn’t publish the value to the pwm_input topic ( there is no ORB_publish() ) . Secondly I want to run this code using ISR and start the driver as well as publishing time_period of pulses to the topic once the controller is powered on.
Can you just tell me the direction to proceed.
You could either create another “driver” (ISR or HPWORK) that reads from pwm_input (/dev/pwmin I think) or reimplements the portion of pwm_input you need.
Then once you have the data calculate RPM (possibly configurable via a param) and publishe an esc_report (https://github.com/PX4/Firmware/blob/master/msg/esc_report.msg).
I’m thinking of editing the pwm_input code itself. As of now pwm_input start will load/start the driver . Can i edit the code such a way that pwm_input start will start the driver as well as start the function pwmin_tim_isr(int irq, void *context) which will calculate the pulse time period using isr ? Then I can publish the data in the publish fucntion and the whole code will run in the background similar to a daemon app. Hoping thats possible
Is it possible to edit a driver code to a daemon app ?
There’s no other app running, the main just does the ISR setup. It’ll ultimately be easier for you to create your own module.
I am trying to use the same file (pwm_input.cpp) for reading RPM. It works well but my Pixhawk board freezes/hangs randomly. I strongly suspect that my RPM reading module may be the reason. Due to safety concerns related to this random phenomenon, I am unable to go for flight.
Any further leads in this regard would be highly appreciated.
@Albin : Were you finally able to use pwm_input.cpp for reading RPM from your sensor?
There is a possibility to use I²C RPM sensor.
It takes the advantage over direct sensing of PWM by MCU. Because it is basically I²C counter and offloads the MCU. Therefore it could be used even for high rpm propellers without risk of high MCU load.