Drone Motor Control – 12/13/2020 – Test Stand

Starting from scratch and a limited budget I decided to buy a motor, batteries, and an XPS to programmatically adjust the speed of a standard propeller, to get a gyroscope to tinker with rudimentary PID feedback, and to build a test stand to tinker with and learn motion control.

Now, to start putting things together. The stand is just a way to hold everything together and allow for lift generated from the spinning propeller. I thought, let’s start easier and simply control speed with a resistor pot. I took the 5V signal generated by the XPS, and ran it through a resistor pot, and took an analog reading using an Arduino Nano.

I am using wood glue, that’s just a paint stick, some through away aluminum rod from a vertical window shade. I really don’t have much money to spend here, but that’s not going to stop me.

Nutrition Tank – 12/10/2020 – Construction 1

Starting with the water tank (a styrofoam box), I found DIY videos demonstrating 2 techniques for creating a vortex.

Magnetic Stirrer


I am starting with the drain technique because in the future I wish to incorporate the Peltier chillers as well. We use a pump to move water into an overhead bottle that will drain into the larger container filled with water. Here are some pictures of the early construction.

So, I have a small vortex. Through experimentation, I found the vortex disappears if the water level is to high. You can see I have a small metal manifold inline with the tube. This will be used later in an idea I have to cool the water using thermoelectric Peltier devices. Also, the cardboard here is kind of flimsy so I will need better materials. During the experiment, also noticed the water absorbs into and leaks from the bottom of the Styrofoam box. I want to keep the Styrofoam as an insulator as I cool the water.

Nutrition Tank – 12/11/2020 – Construction 2

It was obvious that we needed to improve on our construction materials. Carboard box is rather flimsy, and the water bottle would lean sideways. I went to Michael’s and boosted some of my crafting supplies, as well as some tools to improve on build quality.

Also, looking forward, an important aspect of watering plants is keeping the PH at a constant level. In order to do this I need to monitor the PH, making adjustments in a systematic way. I picked up a PH sensor, and 2 Paristaltic pumps. The plan is to add PH-up or PH-down solution to the water depending on the readings from the sensor. I am using an Arduino Nano to monitor the reading and control pump flow. The Nano reads the PH with an analog input, and controls the pump via a PWM. I created a circuit and put things together to prepare for writing software that would both take all of these reading and control the peristaltic dousing pumps.

Drone Motor Control – 12/28/2020 – PID control

Implemented a PID loop to hold the motor level.

I experimented with values for the PID coefficients. I was satisfied after seeing a proper rise time and seeing the drone motor flying stably level. I believe I could improve smoothness by averaging the accelerometer values. Also, I could make 2 separate states with different coefficients, one to quickly accelerate the motor PWM before the motor turns (from 0%-~40% duty cycle), then to continue rising slowly and in a controlled way to maintain a stable and level condition. Already knowing this, I will contemplate future goals for this project.

Nutrition Tank – 12/28/2020 – Peltier Cooling 2

Continuing to experiment with the Peltier devices. I tried doubling the size of the heatsink, and using a stronger fan.

I the heat sink continued to get exceptionally hot. Because of this I tried a better heat sink. I tried attaching a heat sing with larger fins and fan attached. It employed heat pipes, designed to transfer heat away from the source with more efficiency.

and with this setup, I was able to observe the attached plate and heat sink did not get so hot, but, the junction between the Peltier device and plate was. I am not sure how much heat these devices are capable of handling. I believe I need to start measuring these temperatures to make much progress from and will buy a thermo-couple reader to get these temperature values

Nutrition Tank – 12/23/2020 – Peltier Cooling 1

The 12V power supply just arrived. No to start putting the cables and connectors together. Also, I have the components for a Peltier Cooling system so looking forward to see if this will all work properly to reduce the water temperature as I pump water through the manifold.

A little bit of thermal paste later, some zip tie’s to clamp the heatsink and manifold to the Peltier coolers and we have something to begin with.

And this would be no fun without being able to watch the temp change as I pumped water through the manifold; so I went ahead and added a hole for the temp sensor and wrote an Arduino sketch to read the temp.

And, adding the code to github here

GITHUB – nutrition_tank

So, after starting the pump, plugging in the cooling unit, and watching the temperatures I realize this was just a start. The whole thing looks like it needs to be reconstructed due to the way the top tier is unsecured and it being made with a plastic soda bottle. I wanted to increase the vortex action, so I drilled a larger hole in the bottle cap. Now the water drains as soon as it enters the top.

The Peltier cooler works, and I could feel the water being refrigerated by touch. Unfortunately I can only cool the water about a minute before the heat side of the device gets very hot. I need to cool the hot side much better; bigger heat sinks, larger fans, etc…

I am also concerned about the quality of temp/ph meter I am using. I need to test everything for a longer duration. I am thinking of ways to log the data, and visualize everything. Possibly a display for the tank, and perhaps data communication to acomodate a database.

Still, things are working as well as expected. I placed a glass aquarium in the styrofoam box to deal with the water seeping through ($30 from the local fish store). I think I did enough for the day and look forward to improving all the different aspects of this first prototype. I shall receive the PH-up and PH-down solution any day and will test the paristaltice pumps soon.

Drone Motor Control – 12/21/2020 – Vibration Issue

It turns out the issue with noise in my readings from the Accelerometer were not related to the downdraft created by the propeller. Before finding this out, I built a small enclosure from a bottle cap and a piece from the foam board I purchased at Michael’s. It was fun to use the Dremel tool and Dremel/drill press stand I recently picked up at Home Depot. I cut off a small square the size of the bottle cap and used the Dremel tool to shape and cut the holes for an air tight fit. Here is a picture of the work

After making the enclosure, I realized the numbers still acted erratically, I tried mounting the GY-91 module under the arm, and under the fulcrum as well {that is as far from the motor and away from the down draft}. The issue remained. I had a feeling this could be caused by the vibrations, so I looked into this on Google. The search confirmed my suspicion.

I was contemplating to fix this mechanically by adding dampeners on the mounting points of the motor. I could see the vibrations were noticably mor pronounced at the end of the armature and considered adding reinforcements to the arm. Thinking of how to handle this in software I thought of using trigonometry on the x and z plane of the 3-axis accelerometers. The logic behind this was the noise would be captured instantaneously on both axis. The math would cancel out the noise.

It turns out none of these ideas are the solution. I found the solution within the device itself. Their is an internal low pass filter that can be enabled by configuring one of the registers. The register we are interested in is 1D. Here is a link to the PDF containing all of the registers that may be set, and where the locations of the readings are.

I think I will start my github repository for this project. That link is right here. From here you will be able to see how I write to registers on the PY-91 and how I read the values in registers. This is all done on the I2C bus.

GITHUB – Drone_Motor_Control

The low pass filter solved the issue, and I am not seeing stable values that I may use for the PID algorithm while the motor is running.

Drone Motor Control – 12/19/2020 – read GY-91 w/ I2C

Going to start reading the gyroscope tonight. This is the GY-91 module, a sensor fusion device with accelerometers, a gyroscope; it has a digital compass and it has a barometer. I am most interested in the accelerometer readings, particularly in the y direction. As the board becomes level this value will approach 0. This is the tutorial I used to obtain and best understand the values I can read from this board


Fusion sensor chips are pretty interesting. With the rather new MEMs technology available they are able to fit a lot on these little chips. Gathering accelerometer data and gyroscopes and magnetoscopes. Their is a lot to read in the manual/datasheets. Taking care in utilizing good practice; as in writing certain configurations to proper registers and making so everything is correctly initialized for your math. Also, I liked the methods in this youtube video for bitbanging data out from the registers

While experimenting, I noticed a flaw in my design. The accelerometer operates correctly when the propeller is turned off, but once you start flying with the drone motor the number fluctuate wildly. It appears the airflow from the propeller is detected by the module mounted directly (unprotected) underneath. I believe mounting the GY-91 under the arm and building a protective covering around it though will solve the problem.

Nutrition Tank – 12/18/2020 – Tasks

Nutrition Tank

TODO list

  1. Improve how Ph-up and Ph-down bottles are secured under the tier
  2. Establish communication between Ph/TEMP sensor module and Arduino Nano

  1. Super glue, awesome stuff
    • going to scrub the glue off one of the little containers as well. These are old vape juice bottles. I modified the caps a bit with pliers.

2. This particular PH sensor module is the PH-4502C. Their are 2 steps to calibrating this sensor. First, to center the reading within the range of 0-5V. I followed the instructions found here


The offset didn’t make it all the way down to 2.5V, and seemingly to hover at 2.7V. I will verify the sensor is working correctly with calibration fluid as soon as my 12V power supply arrives from Amazon. Waiting for supplies, then I will hook everything up and test the perstaltic pumps in circuit as well.