DIY - RPM and Temperature Data Logger
© Mark Qvale - July, 2019
DIY Test Tool |
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 to measure and log the RPM of a brushless motor plus two temperature probes.
This DIY tool 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, like a cars cruise control, then fly for a short period (5 minutes) and capture the logging info. 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.
- 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.
First flight set-up |
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 two 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 factor - Black = Positive, Red = Negative. While looking for a replacement 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 ~$18 plus any shipping.
Schematic
The schematic for this build can be seen here-
- 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-
Some of the proto set-ups
|
Current board (top) |
Current board (bottom) |
Code & Results
The Arduino code can be downloaded here- RPM_Regulator_v16r2.ino
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 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 bit just keeps the relay and throttle output in a "fail-safe" mode if there is no input from the RX switch channel.
- 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/
Bench Test Results
Below is an Excel chart showing a bench test run using a 4S Li-ion battery pack which was charged to 15v and over 30 minutes run down to 12v (3v/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). 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.
30 minute test run |
In-Flight Results
TBA
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
Comments? Questions?