DIY - In-Flight RPM Regulator and Temperature Data Logger

From ItsQv
Jump to: navigation, search


© Mark Qvale - July, 2019

REG00.JPG
  DIY Arduino Tools!



Introduction

Folks on RCGroups and FB have asked about some of the test tools I use to get the recommendations, charts and numbers I use in my posts. This article describes the build of a tool with the ability to set a steady state RPM while flying, like a cars cruise control. It also measures and logs the RPM of a brushless motor plus two temperature probes.

This DIY tool first came from a need to be able to test components at steady state power, current and RPM levels to fully understand the loads being placed on the components. The first version of this device served to regulate the RPM at a steady state regardless of voltage supply to test battery packs and ESC's. I then re-configured the tool to regulate the current pulled from the ESC to further test battery packs in a controlled environment without the need for an expensive lab quality power supply.

The latest effort, shown here, is to make this a stand-alone in-flight tool as a means to help with choosing the best motors & props for maximum flight efficiency on an FPV fixed wing project. The goal is to have the ability to set the RPM then fly for a short period (5+ minutes) and capture the logged data. Doing this on several different props running the same airspeed in every case will give excellent real-world comparison information.

Tool Description

The tool captures RPM and two temperature values and logs them to a Micro SD card as a CSV file type which can be read and analyzed in MS Excel.

  • RPM is captured using a HobbyWing RPM sensor which is the same as the Eagle Tree and Spektrum RPM sensors.
  • RPM can be set using the TX while flying as either direct pass-through or regulated rpm (cruise control).
  • Temperature is captured using two glass bead NTC3950 thermistors commonly found on 3D printer set-ups.
  • One temp sensor is epoxied onto the motor cross mount and the other is slipped under the ESC shrink cover on the MosFet side.
  • One extra radio channel is needed to activate the pass-through/regulated functions.


REG03.JPG
First flight set-up bits


Parts

The following are the parts used in the latest version of this tool-

1. Arduino 5v/16mhz Pro Mini Board
2. Omron 5v SPDT Signal Relay
3. Hobbywing RPM Sensor
4. NTC3950 Thermistors
5. Pin headers
6. Double Sided Prototyping PCB
7. 2x 100k Ohm, 1/4 watt resistors
8. 2x 10nF (103) capacitors



Part Selection

Arduino Pro Mini - I wanted a small board with enough IO to handle all the tasks. The Pro Mini or the Arduino Nano both easily fit the bill as does the Teensy LC board. The Pro Mini was finally selected because it works and I can find them for around $5 each.

Omron Relay - After trying many different software attempts to create a smooth pass-through mode for the signal from the flight controller directly to the ESC, I finally decided to use the normally closed side of a relay to accomplish this task. There are few reasons for this-

1. If the board fails for some reason the relay will close to direct pass-through making it possible to continue flying the plane.
2. Having a direct, hard wired pass-through makes it completely smooth which is important in how the regulated section of the software works.
3. Inexpensive ($1.79)


HobbyWing RPM Sensor - I actually started with an early Eagle Tree unit that had an issue with how the power wires were from the factory - Black = Positive, Red = Negative (wtf?). While looking for another pre-built solution I found the HobbyWing version which according to my O-scope produces the same output. Bonus is they are less than a quarter of the price of the Eagle Tree units ($4.49)

NTC3950 Thermistors - I selected this type of temp sensor because I had them already and they are really inexpensive ($1.40 ea). Also they are very easy to attach to the motor and ESC because of their size.

All together then, the parts for a single build cost me about $18.

Schematic

The schematic for this build can be seen here-

REG02.jpg


  • Power for the Arduino board, RPM sensor and Micro SD shield (MSD) is supplied from the ESC. In the event the ESC is an Opto type, a separate 5v supply will need to be used.
  • Power to the temp sensors is supplied from the Vcc pin on the Arduino board.
  • The mode switch input is a single signal wire from the chosen switch channel on the RX.
  • Throttle-in comes from the flight controller or RX in the case where no flight controller is used.



Board Builds

Here are some images of the first few versions and close-ups of the latest build-

REG01.jpg
Some of the proto set-ups
1. First test board
2. First Regulator only board
3. First data logger for in-flight
4. Bread-boarding the new relay
5. Current build


REG06.JPG
Current board (top)


REG05.JPG
Current board (bottom)



Code, Use & Results

The Arduino code can be downloaded here-

v16r2 - July 24, 2019 - RPM_Regulator_v16r2.zip

Below are some details of the major code sections:

Throttle Value & Percent
This section covers collecting the throttle-in PWM value (thrIn) using a PWM read library. I chose using this library approach as opposed to a simple "pulseIn" capture because it gives cleaner results. Added to this I am using an exponential smoothing filter to calm down the jumpiness of the input. In the last part of this I convert the throttle input to throttle percent for displaying in the data file.


Temperature Captures
The two temperature probes are picked up using the analog inputs A0 & A1. The code which configures these two inputs for the data file is taken directly from a code snippet found at CircuitBasics.com. The output to the data file is given in degrees Fahrenheit but can be changed to degrees Celsius by commenting out the two lines where the conversion is made. In the latest code, v16r2, this is line 137 and line 142.


Throttle Pass-Through
This piece of code takes the input from an RX channel and makes sure the pass-through relay is left in its normally closed state allowing a direct hardwire path between the throttle input and ESC output. It also holds the pass-through switch state at 0.


Throttle Regulation
Using the RX switch channel, this sets up the throttle regulation by first setting one-time values for the RPM set-point (rpmset) and initial throttle out setting (thrOut). Next, through three "IF" statements the rpm is checked every 2 seconds (RST) and compared to the rpm set-point. If the rpm is low the throttle output is increased by 1, if the throttle is high, the throttle output is decreased by one. The final value is then sent to the ESC.
Note: I did try using a PID controller here but the tuning became problematic because of the filters and timers needed to stabilize the rpm read. In the section (below) "Bench Test Results" you can see how well this simple regulation method works.


Switch Safety
This section which looks for a switch channel input of less than 900ms (PWM) which generally means there is a connection or RX problem. It keeps the relay and throttle output in a "fail-safe" mode if there is no input from the RX switch channel. This is


RPM Signal Capture
This piece of code was found while doing a search on "HobbyWing RPM Sensor" and works quite well. It did present some issues when I tried to use a PID control loop and also before I added the SPDT relay. Additionally, I added a second exponential smoothing filter to help stabilize the rpm read and rpm stabilization. The code for this can be found below.
https://www.locarbftw.com/using-an-arduino-to-read-rpm-from-the-hobbywing-rpm-sensor/



Radio TX and RX Configuration

This is pretty simple. A single channel is used to activate the Pass-through/Regulate modes from a switch on the Tx. Select a channel for this function and set it up on a switch with the following parameters-

Switch position 1 = +100% This is Pass-Through mode
Switch position 2 = -100% This is RPM Regulate mode (Make sure this is not below a pulse width of 900ms)



Using the Tool

It is very simple to use! Assuming you have bench tested after getting it all put together and run the Arduino serial monitor to confirm the card is initializing and collecting data, first, connect the device into your plane-
My Pin-Outs

REG09.jpg


2. Plug a Micro SD card into the card shield
3. Connect power and listen for the ESC to initialize which confirms it is in "pass-through" mode
4. Do all your normal pre-flight checks and tests including checking that the throttle works as you expect
5. Launch the plane and fly to a straight and level position at a speed above stall
6. Flip the mode switch to Regulate and it should now stay at this airspeed until you move the switch back to Pass-through
7. When ready flip the mode back to pass-through and land the plane.
8. Pull the Micro SD card and check the log to see time, rpm and temp data logged
9. Run this way on several props all at the same air speed and you will be able to see direct in-flight comparisons of what different props can do.



Bench Test Results

Below is a set of Excel charts created by my Medusa Data analyzer showing a bench test run using a 4S Li-ion battery pack which was charged to 15v and over 27 minutes run down to 12.4v (3.1v/cell). The test was started at an RPM set-point of 5075 rpm which consumed 55 watts of power. You can see the RPM is maintained at a fairly steady state with a variation of +/-50 RPM for the entire run. This is as good a resolution as I can get with the components used (and my programming abilities).

REG11.JPG


You can also see the current increases as the voltage drops which is a good indication that the power (in watts) into the ESC/motor was also steady state.

REG13.JPG


REG15.JPG


As expected, the device continually checked and adjusted the throttle to comensate for the measured RPM readings.

REG17.JPG


In-Flight Results

Finally got the data logger out for a few flights this morning on the nearby Eldorado Drylake!

REG35.jpg
Ready to test!


Couple notes here:

  • Conditions 0-2mph wind, 101F(38C), 24%RH, 1710ft(521m)ASL
  • Plane is my Mini Talon (#4)
  • Motor used is a Cobra 2221/12-1250kv, ESC is a HobbyWing 40A-v5 and pack is a Multistar 6600/4S
  • AUW with this test set-up - 1745g
  • Flight controller is a Matek F405-wing running Chibios/APM firmware


OK, below is a summary chart of the days tests. I set the plane up on each flight to fly straight and level at 37mph(60km/h). Once this was done, the mode was switched to "Regulate" (cruise control) and the RPM is held at a steady state until the switch is set back to "Pass-through" mode. There was little to no wind and each test was run in two directions (North and South) for about a mile each and all data shown was averaged over the entire distance while regulate mode was on.

REG31.JPG

On the chart-

Aspect ratio is simply the length divided by the pitch as a size reference
Throttle percent is what shows up in the OSD and in the case of the 9x6, 38% is equivalent to a pulse width of 1385ms (in my case)
RPM Average is taken over the entire run with the regulator managing the throttle
Prop-Speed is the calculated speed based on pitch**
Airspeed was taken with an analog AS sensor
Power was the average of the logged voltage times the logged current
Efficiency was the average of the logged efficiency


It is fairly clear the best prop of this group, in terms of efficiency, is the 9x6. I usually fly an Aeronaut 9x7 folder and would expect it to be very close to the APCe 9x6 numbers which is why the Aeronaut is my favorite prop. It is quieter, accelerates a bit quicker and when folded offers great gliding distances.

**A little about prop pitch and pitch speed
Pitch is a theoretical measure of a props potential for moving through a fluid during a single rotation and is based on the blade angle at 75% of the blade length. It does not usually take into consideration the aerodynamic lift of the prop blade shape or any other aspect of blade shape that may increase or decrease the actual pitch speed. Because of all the different prop styles and blade shapes available, the actual flight performance from one brand or style to the next can be quite different. So, pitch or prop speed is a calculated estimate for comparative analysis and not a perfect measure of what a prop will actually do in-flight. As a general rule of thumb, the pitch speed will be higher than the plane speed but it is not uncommon to get slightly more plane speed than the calculated pitch speed when the pitch is low (high aspect ratio) and the power system is overproducing thrust as in the case of the 10x5 shown above.

A Second Test Run

For a second look I ran a similar test, same airspeed and location. In this test I changed the motor to a lower kv Cobra 2221-940kv and ran three different APCe props. The first prop was the same 9x6 prop of the previous test as a baseline and the other two were deeper pitch props.

Test Conditions

  • 2-5mph wind, 99F(37C), 12%RH, 1710ft(521m)ASL


REG33.JPG

Seeing the 9x7.5 is a little more efficient is not surprising. I don't fly the 9x7.5 prop because it is noisy, launching is a little more difficult and acceleration/climbing is terrible compared to the 9x6 (or 9x7AF). Seeing the 9x9 as the lowest efficiency in this group is also no surprise. The MT is not a speed plane and this prop on a small motor like the 2221 is a bit too much at a speed of 37mph where the prop is still stalling (and wasting power).

One Issue

First, I am not an expert at writing or optimizing code. I am also not an electrical engineer (I am a retired Mechanical Engineer however) so if you see something that doesn't make sense or could be done differently with better results, please don't hesitate to contact me (bottom of this page) and let me know your thoughts.

Now the ONE ISSUE
The one issue that drove me crazy while trying to get this to work in a plane is the fact the HobbyWing RPM sensor is massively affected by any 1.2G VTx. I chased this problem all over the map until I finally (simply) connected the RPM sensor to my oscilloscope on the bench and watched what happened when I turned on a 1.2G VTx which was in a plane at a distance of ~6 feet (2m). There were no connections at all between the plane and the bench test set-up. On the other hand a 5.8G, 600mw VTx has no affect so that is what I will use in testing.

See Also