Close
0%
0%

Measuring Engine RPM with the Pixhawk

Using a Hall effect sensor and the Pixhawk to measure engine RPM

Similar projects worth following

The Briggs and Stratton engine used on #Goliath - A Gas Powered Quadcopter utilizes a magnet on the flywheel to trigger the ignition coils. This magnet will be utilized for measuring the engine RPM with a hall effect sensor under the engine cover.

Hardware

The Pixhawk board has six auxiliary pins that can be configured as pulse width modulation (PWM) or General Purpose Input/Output (GPIO). In GPIO mode the AUX pins can be used for measuring frequency. Unfortunately the AUX pins have to be all PWM or all GPIO and can't be a mix. Since some of the AUX pins are being used for servos, this means they can't be used for frequency detection. Additionally the analog to digital (ADC) ports don't have interrupt capability, meaning that they can't be used for frequency measurement either.

This means that for the current application, an off-board frequency measurement option is needed. An Arduino will be connected to the hall effect sensor to measure the frequency. The frequency data will then be based to the Pixhawk via I2C. A 5V Trinket Pro was selected to it's small size. A sketch of the circuit is shown below.

Software

Arduinio Sketch for Trinket Pro

https://github.com/mccloudaero/goliath-quadcopter/tree/master/avionics/rpm

  • 1 × Pixhawk Flight Controller
  • 1 × Trinket Pro 5V Arduino Board by Adafruit
  • 1 × SS443R Sensors / Hall Effect, Magnetic
  • 1 × 10k ohm resistor
  • 1 × Diode

View all 7 components

  • Arduino Hardware Completed

    Peter McCloud04/07/2017 at 22:05 0 comments

    The Trinket Pro (arduino) hardware has been soldered together and has been installed on the vehicle. Below is the Trinket Pro connected to the Pixhawk I2C and the hall effect sensor. The arduino is powered from the 5V power provided by the Pixhawk I2C port.

    The hall effect sensor is a uni-polar sensor meaning that the sensor only gets triggered by a specific orientation to a magnetic field. For this case the back of the sensor case has to be facing the flywheel magnet.

    The sensor was also re-positioned to be level with the middle of the magnet.

    A quick test of the setup was done to make sure the electronics work. The arduino was configured to blink the on-board LED when the magnet was detected. Then the engine was spun by hand to pass the magnet by the sensor. The arduino correctly detected the magnet and flashed the LED each time the magnet passed by.

    The next step is to add the logic to the arduino to compute the frequency and then pass that to the Pixhawk via I2C.

  • Switching from the ADC port to I2C

    Peter McCloud03/18/2017 at 16:29 0 comments

    My initial concept was to use a Hall Effect sensor connected to the ADC port on the Pixhawk. However it turns out that using the ADC port isn't an option. It turns out that the ADC ports don't support interrupts. The ports are good for reading sensors, but without interrupts, there's no way to count the pulses to get a frequency measurement.

    There are ways to measure frequency with the Pixhawk directly. There are 8 main pins and 6 aux pins that are capable of measuring frequency. However the 8 main pins are being used for controls and the 2 of the aux pins are being used for servo to control the engine (throttle and choke). This would leave 4 open aux pins, but it turns out the for my particular hardware (px4fmu-v2), the aux pins can either be all PWM or all GPIO, but not a mix. Since the 2 servos are required, that means the rest are unusable as GPIOs.

    This means that most likely I'll have to an off-board option. A separate device to determine the frequency and pass the data to the Pixhawk via on of the many other data ports. The simplest option for now appears to be using an Arduino to measure the frequency and use I2C to pass the frequency measuring to the Pixhawk. I've got some Trinket Pros on-hand, so I'll start prototyping with that.

  • Sensor connected

    Peter McCloud03/13/2017 at 03:07 0 comments

    This project started almost two years ago when the hall effect sensor was first installed underneath the engine cover. The sensor is in a TO-92 package and wire leads were soldered on. The wire was run through a hole underneath the flywheel. The sensor is held in place with a little bit of RTV. Below the installed sensor is shown along with the magnet that is present on the flywheel.

    Today the sensor was connected to the Pixhawk ADC port. The wire leads were spliced onto 3 pin Hirose connector and a 10k resistor was added between the power and signal lines.



    The next step is writing the software application that will read the sensor and determine the RPM.

View all 3 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates