Friday, October 26, 2018

DynoDrone: A Pythonic way to model Quadcopter builds

I have always been a fan of mechanical builds. When I was a teenager I was fascinated with cars. Building them, breaking them down, and especially tuning them. One program I remember fondly from these early days of tuner glory is "Desktop Dyno", a system for modeling engine performance without expensive hardware. In this post I will discuss how I used Python to create a "Desktop Dyno" for flight systems called DynoDrone.


Like most people, growing up I didn't have the money to buy three different turbos to try on a car, nor did I have access to the expensive Dyno systems needed to effectively compare their outputs. What I did have was a desktop computer, and modeling software called Desktop Dyno which allowed me to approximately model the output of a design before I invested the money and time in the parts. These days I like to build, modify, and tune Unmanned Aerial Systems (a.k.a Drones). Unfortunately there weren't any cheap and readily available modeling systems for drones. One option is to use a game called the Drone Racing League Simulator. If you are interested in building performance racing drones, this is the route I'd actually recommend trying first. It doesn't target general flight systems though, so it lacks larger frames and props. It also includes a full set of game features like maps, detailed graphics, and communications code I don't need. For all these reasons I decided I wanted to write a more generalized program inspired by the Desktop Dyno of old. Bearing in mind these are only estimates, you can use this system to compare potential builds.

Modeling Flight

The first thing to understanding performance is thrust. I am not going to give a long technical rundown of thrust here. You can read everything you want to know in "Quadcopter Dynamics, Simulation, and Control" by Andrew Gibiansky
There is also an interesting Quadcopter Simulator based on the same work which I used for the propeller class. Thanks to both of these folks' hard work we can jump right to the part where thrust is a result of a propeller of a given length and pitch being rotated at a given speed. The other factor affecting the flight performance of any drone is it's weight. The weight can be thought of as the sum of two categories: Drone System weight and Cargo weight.

Flight and Hover Thrusts


I like this write up describing a way to calculate thrust required. The above picture comes from the post and describes the portion I implemented in DynoDrone. In general, flying horizontally takes less thrust than hovering. The above formula puts it at 20% more, but that can really be affected by things like weather and altitude but ~20% is a good enough approximation for what we intend to use it for.

Torque-Speed Relationship

I think that basically says it all: As the speed of a motor increases it's effective torque goes down. This is something car modifiers discuss constantly. Torque lets you spin something (like a drive shaft or propeller shaft) around an axis. Torque specifically describes how much twisting (or torsional) force is applied to the object. The heavier an object, or more generally the more resistance to turning a load provides, the more torque it would take to turn it. Due to inertia, an object in motion tends to stay in motion. This translates to less force being required to maintain the same velocity. Ultimately this leads to the motor speeding up it's rotation and the cycle continues. At some point the motor reaches it's maximum effective Revolutions Per Minute (RPM) which could be limited by drag on the load or by electrical efficiency. This is the point a motor will have the lowest amount of Torque output but it's highest potential speed. Torque is an important concept in drone performance as well. Torque is the reason you must have balanced Clock Wise (CW) and Counter Clock Wise (CCW) motors on Quad copters. It is also the reason you can Yaw them without a rudder. One final thing to know about torque as it relates to multi-rotor flight characteristics: multi-propeller configurations (3 propellers or more per motor) create more torque at the expense of efficiency. I didn't want to overly complicate my first model so I left off torque for now. It would describe how quickly the system would be able to apply it's acceleration and that is more in-line with the aforementioned DRL simulator. For the same reasoning I assume a 2 propeller design.

Using DynoDrone

DynoDrone Help Menu
Finally! it is time to start talking about the tool. DynoDrone has two modes: RPM or KV. In RPM mode you must already know the maximum effective RPM range of a motor. This is sometimes provided by the manufacturer. I tend to take these numbers as overly generous and shave a few hundred RPM off. The other, far more common rating is the KV constant approximation. For rough calculations, you can treat an electric motor's KV constant as the RPM per Volt (meaning, the speed the motor will turn per applied volt) but This article explains in great detail the actual meaning, however it will get us fairly close. More than enough accuracy for our purpose.
This is always an approximation after all.
python3 dyno_drone.py -b 4 -k 920 -d 550 -c 0 -r 1000
DynoDrone will run the motors through the full range of propeller choices it knows (currently this is all the 2-blade propeller sizes in the Raycorp advertisement). The code uses this data to generate a thrust curve for each propeller. The curves are compared to the thrusts required to fly as well as to hover. Curves are colorized based off their relationship to these values. This graph demonstrates a medium-weight drone of 550 grams using a typical 4 cell Lipo battery (14.8v) and 920KV motors. The background output gives more detail.

I wanted to use this to estimate a bigger build I am working on. An S500 frame is typically one of the larger drone frames around. It is regularly used for videography drones. The Larger frames can support larger propellers (10-12 in blades) and larger motors. This leads to a higher payload capacity. Here is the graph for my S500 build:
Here are the measurements for the props I am most interested in:
python3 dyno_drone.py -b 4 -k 1000 -d 1355.26 -c 0 -n 4 -r 1000
I ultimately decided to try the 10x4.7 and the 11x4.7 propellers This should give the system somewhere in the neighborhood of an 8:1 to 12:1 thrust to weight ratio. This is more than enough to carry a few lbs of cargo (3 kg = ~6.61 Lbs.)
python3 dyno_drone.py -b 4 -k 1000 -d 1355.26 -c 3000 -n 4 -r 500
As you can see from the output, this brings the thrust to weight ratio back down to around 3.5:1, which is still enough to fly and hover, but barely. The system would probably not do well having to maintain ~70% throttle to fly. Dropping the cargo limit to (2kg = ~4.48 Lbs.) gives a thrust to weight ratio of about 4.8:1. and equates to ~65% throttle for flight. This seems like a perfectly reasonable compromise in my opinion.

Conclusion

This was a fun distraction project that turned into a fairly useful tool for estimating drone configurations. I will probably continue to tweak it here and there but if you want to  run it as presented here you can download the DynoDrone Gist.
One last feature I didn't touch on previously that you may want to explore is the ability to add more motors. Consider the 3kg cargo example from before. By bumping the system up to 6 motors and using 11x4.7 propellers we can get a thrust to weight ratio of about 5.5:1 which is fine for a larger camera drone. remember when adding motors to consider the weight of the motor, the propeller, the ESC (if one is to be used) and the connectors. I use ~18g for a generic 920KV with an ESC and connecting hardware. Propeller weights vary so actually weigh them when possible.



No comments:

Post a Comment