Saturday, January 9, 2016

Raspberry Pi Quadcopter Version 4

I went to college after the props shattered and I took the Pi with me, to continue my analysis on how I could tune the gains easier.

I am a part of the Micro Air Vehicles (MAV) Club at ASU, and I took my problem as well as my designs to some of the members there. I got some pretty good feedback from them: first of all, the frame was too wide, and so the props were back washing on to the quad, reducing the effectiveness of the motors, and causing further turbulence that the PID was to slow to correct for. Essentially, I was pushing against myself.

After I came home for winter break 2015, i continued my search for a better design. I found a blog called Pistuffing. Some guy was using the Pi to build a Quad, just like me, and although it was a work in progress, His code was a million times more sophisticated than the chicken scratch I had thrown together. Still, I found that I had the right idea, and so I began to look at his Github Repository, and analyze his code. I adopted the files he had created, and started experimenting. It took almost the whole break to understand it, because I started out having no Idea how to even begin, but eventually I got it.

I bought strips of balsa wood, which is light, and new propellers. I once again mounted everything, and began testing, by tying the four corners of the Quad to chairs, so that it would not flip over or shoot up in to the sky. I learned how to debug code using print statements to narrow down the location of the problem.

I found some flaws in the code, which were causing the quad to just go full thrust instantly, or perhaps that is due to my design. It turns out that the latest version is lighter than anticipated, and so it takes less thrust to lift.

That is the point where i am right now. It may work reasonably, and have found a way to test it. I am going back to college now, but will for sure continue to try and get it to fly in the future.

Quadcopter V.4

Raspberry Pi Quadcopter Version 3

In my last post I previewed that I had bought Brushless DC 3-phase motors with their corresponding ESC's. After doing even more research, I bought a 3 cell lipo battery rated at 1300 mAh (the smallest one I could find.) I also bought a power distribution board to supply the power from the battery to the ESC's, as well as male and female bullet connectors, and 9045 propellers.

A source on the internet showed me that an accelerometer module could be used to find the angles that could be usid as inputs in the PID algorithm, to provide stability to the quadcopter. I had one of those modules in one of the Raspberry PI starter kits that I had gotten. It was the ADXL345

I made the frame of the new design Quadcopter using plywood. which I cut in to shape with a hand saw. I then drilled holes into the wood and screwed the motors and raspberry pi in to place. Because I needed to remove and recharge the batteries for the ESC as well as the Raspberry Pi often, I just stuck those on with tape. The power distribution board went on the bottom, and plastic cups cut in half were attached for the stands under each motor. 

I integrated the PID algorithm in to the code and wrote in a loop that gave me manual control of the base thrust given to the motors.

WARNING: The motors spin really really fast and are dangerous when first testing one, I accidentally set the thrust too high, and the propeller and the screw on top of it shot off the motor, nearly taking out my eye. On a separate occasion, when testing the quad, my mom was helping out, and she cut her finger pretty on the blades, because they were spinning so fast she couldn't see them. 

I was able to control the motors using the same PWM function on the Pi. 

FINALLY! the quadcopter was able to lift up off the ground! unfortunately, it consistently veered off on to one side or the other. I was able to correct it to an extent by changing the gains on the PID algorithm, however it could not reliably lift off the ground more than a foot without violently tipping and at that point I would have to shut down the code. 

I once again read some more online, and found a gyroscope module, which I had once looked at, but because I didn't understand the vital differences between the gyroscope and accelerometer, dismissed it as the same thing. but more expensive. This time I got a better sense of what was happening in the code and in the accelerometer module. the motion of the aircraft and the vibrations caused it to be a lot more unreliable in flight, whereas while testing it, it was fine. I bought an imu unit (MPU6050), and it gave me much more stable in flight angle readings. 

This looked promising, however, the problem with the PID gains still persisted. How would I tune the PID gains? they had to be tested manually(no easy mathematical solution), and I couldn't allocate a lot of space to trying it over and over, because I lived in a small apartment at the time, and needed a good wifi connection to use the Pi. 

I tried several times, and the one last time I changed the PID gains, one of the motors revved up a lot more than the others, the quacopter flipped on its back, and all of the propellers shattered. 

Stay tuned for the stunning continuation to the tragedy!

Raspberry Pi Quadcopter Version 2

After facing the plethora of problems with batteries and voltage drops in the first version, I decided to do some more research and found out that the motor speed and the propeller size I had gave me a much smaller total thrust than the weight of my quad. so after using an online calculator for the thrust, I decided to buy better motors and larger propellers.

What I realized was that newer quads use brush less motors rather than brushed ones because they are much more efficient at using power, and can spin much faster, but they cost a whole lot more than regular brushed dc motors, because you have to buy electronic speed controllers to manage those better motors. However this ends up costing around a hundred dollars, and I didn't want to spend that much.

I got brushed motors that were larger and more powerful than the previous ones, and I also bought size 1045 plastic propellers. Together this combination could theoretically lift 1kg, which was almost exactly the total weight of the one I had. The problem I found was that there motors were not meant for Quads, and so the rod on which I was mounting the props was too thin. I temporarily wrapped the mounting rods with masking tape to make them thicker, so I could mount the props. I also bought a small portable battery pack with a USB connection to provide the 5V, 1A power that the raspberry pi required. It was really a pain, because most lightweight portable batteries are 0.5A sources. I mounted everything on the styrofoam frame, and taped everthing on securely

I wrote a better version of the code inn python, and spend a while learning about PID algorithms, and how I could use them to make my quad have stable flight.

This time, the problem I faced was that all the batteries and the components were still too heavy for the quad, and moreover, because the motors were not made for air crafts, they did not spin as fast as they should have because of the resistance from the propellers. After a few more days of research and testing the motors at higher voltages etc., I decided that making a quadcopter using regular dc motors was not practical and a waste of time and energy.

I instead started to look at if I can use brushless DC motors like the ones they use in professional RC quads, for my project. It turns out that you can, however I had to make a pretty large investment of around $100 to buy the right motors as well as electronic speed controllers (ESC's)  for the motors.

It is really cool how the brushless motors work. The rotation happens due to the changes in a magnetic field in the coils of the motor, which oscillate in three phases. I decided to use those new motors in Version 3. Stay tuned and in my next post I will show you what design changes I made and the challenges I faced.  

Monday, December 21, 2015

Raspberry Pi Quadcopter Version 1

In the summer of 2015, I started designing a quadcopter from scratch. I decided to use the raspberry pi as the main flight controller Because I had one, and it is relatively light weight. Disclaimer, I started this project with next to no knowledge as to how I would go about designing and building the quad. 

After a few initial days of research as to what it would take for me to build a quad, I decided to use the motors and props of the Syma x5 quad that I already had. The Raspberry Pi would be on board the quad, and after seeing a video online about a quad some guy had built, I decided to use styrofoam as my mounting surface. I also realized that in order to control the motors separately, I would need two H-Bridges, each powering and regulating a separate motor. The Syma x5 uses tiny DC motors, and bring the props up to a suitable speed by using a couple of gears. i was using the same props, so I had no problems with that. The motors needed a 6.6 V supply, so i just used the same lipo battery pack that came with the Syma. 
I connected to the Rasperry Pi via SSH from my windows machine, and for that I also had to setup a wifi adapter. A big problem I realized was that the raspberry pi also needed to be powered, and it had to be through micro USB, and after some more googling, I found that it had to be 5V and 1A, and most lightweight commercial power packs were 500mA. To power the Pi as well as the wifi adapter and use so many of the GPIO pins, I would need a substantially heavier power source. I decided to worry about that later, and first just focus on getting my motors running using the H bridges. 
Several online tutorials showed me how to use the basic bash commands, to access the raspberry pi via SSH, and to open up the nano editor to code in python. I also learned how the H bridges worked, and how to wire everything up. Finally, learned to use the GPIO libraries in python to send a PWM signal and. I had not learned Python as a language before, so at first I was just copy pasting, and it took a few days to understand the code, as well as how the language worked at a basic level. Meanwhile, I just used a couple of long wires running from the GPIO Pins to the  H-Bridges. I got a sheet of styrofoam from a hobby store and cut it in to the measured lengths, and cut out open portions in the center. (side note: when cutting styrofoam, and mounting the motors, the styrofoam bits will get everywhere, and cleaning up will be a pain, so put a plastic sheet underneath your working surface.) After mounting the motors in to the sides of the styrofoam, I wrote a small program in python that just started the signal, changed the duty cycle a couple times, and then stopped.
The motors spun, and changed speeds when the duty cycle changed, however the speed that they were getting was not enough to even lift the frame, without the raspbery pi or its battery. The Problem i found was that the H bridge was poorly designed, and a forum told me that the bridge sapped about 2 V from the power input. In the end, this version did not have enough thrust. So I would have to make some design changes. 
In my next post, I will show you What design changes I made, some problems I faced, and hopefully, I'll get my quadcopter to fly! 

Monday, December 15, 2014

Quadcopters (uses)

  1. transferring power to lightbulbs through the air, like a flying power outlet. http://www.techthefuture.com/energy/scientists-turn-quadcopters-into-flying-power-stations/ 
  2. hover bike (uses the same tech as quad copters, but can carry a much greater weight. http://www.dailymail.co.uk/sciencetech/article-2737833/Fly-like-Stormtrooper-Amazing-video-showcases-futuristic-hoverbike-set-sale-not-size-set-45-000.html
  3. Multiple quad copters catch and throw balls by moving together like a swarm.  https://www.youtube.com/watch?v=tWzt0COWnJo
  4. Quadcopters and airplanes fly and navigate obstacles autonomously. http://www.acceler8or.com/2012/11/encouraging-developments-in-quadcopters-w-lots-of-video/
  5. using xbox kinect to make qudcopters follow gestures. http://www.acceler8or.com/2011/12/quadrotors-will-do-everything-well-almost/
  6. quadcopter that uses gps to navigate. http://www.gizmag.com/3d-robotics-iris-gps-guided-quadcopter-drone/28818/

Thursday, January 23, 2014

Security

I was thinking about security today, and how reliant it has become on technology. In my law class we watched a video of three scam artists and how they robbed a bank. The security cameras were in place, but that did not stop them from stealing a $35,000 rolex. We are rolling in to an age where almost everything is connected to the internet. Online security will become a huge industry of it's own in the future. The current security systems rely on complex mathematical algorithms to encrypt data. This will only go so far. we need a better way to defend our privacy. You need something that can be transfered to other people, but can not be just simply guessed. A method of protecting your computer that I thought of is that a mechanical trigger would begin any downloads, to ensure a safe computer. also, a fake projection of the computer could be used to download the file and check for damage. I will think on this further.

Wednesday, January 1, 2014

Tech 2013

Surfing the web these past few days, I have been seeing a whole lot of "Best of 2013" reviews for all sorts of stuff, from Movies, to TV shows, to youtube videos. I thought, why not come up with a list o my own personal best of 2013 technology and science developments. I will keep the list to a short 5 items due to my poor memory, in no particular order whatsoever.

5. Google Glass: This google product gained quite a bit of popularity because of it's diversion from the meta of modern technology. The concept in and of itself of an "iron-man"-like way to gather more detailed information about your surroundings, and a hands free device, is what I believe had the biggest impact on everyone's imaginations. Other than that it seems to have the same capabilities as a smartphone. I put it in my top 5 list because I think that it is a fairly large step forward in the way humans will use technology in the future, and the full cyborg transformation. ;)

4. Drones: This year was big for drone technology. The government amended it's drone policy, and perfected military warfare and espionage drones. The quad-copter personal mini drones grew in popularity, for recreational use. Even Amazon launched it's delivery via drone experiment. To me, the future seems optimistic in this field. I can just imagine swarms of drones zooming through cities to windows of high rise apartment windows, carrying pizza. Of course, it would sound like living in a bee hive, but the luxury of laziness has it's drawbacks.

3. Graphene Aerogel: I loved this news when it came out in march. Chinese scientists developed a material so light that it can sit on a dandelion without causing any damage. It is the world's lightest substance. this definitely deserves the top five list, despite it's lack of popularity, because it has so many applications. This will be used in the future in all aviation, scientific instruments, and environmental defense, bcause it is just so versatile. One can never have something light enough in engineering.