Wednesday, March 4, 2015

Early Software Setup

With the physical setup pretty much out of the way, I moved on to the software setup. As I mentioned in an earlier post, I chose to use the Adafruit 16 channel PWM hat and that took a little setup. There are some steps to be taken to be able to use I2C on the Raspberry PI. To set this up yourself, take a look at Adafruit's I2C setup tutorial and then their pwm hat setup tutorial. I downloaded some of their test code to make sure that I set everything up right and it worked! The only issue was that it didn't work when I replaced my test servo with one of the Electronic Speed Controller (ESC) control wires. The motor would beep which didn't make any sense and I later found out that I was somehow entering some kind of programming mode. But there was another issue I had to work out...

The original intention of this project was to write my flight control program in C++. The issue is that the PWM hat control library from Adafruit is in Python. Then I found some test code for the MPU-6050 Gyroscope and Accelerometer chip but that was also in Python. I looked around to see if anyone had ported the library to C++ and found that Adafruit made an Arduino library. This was interesting because Arduino code is basically C so I figured I could use it and convert it to C++ libraries and it should work! right? Well, it turned out that the library for Arduino has the Wire.h library as a dependency. This doesn't work for Raspberry PI. I then thought I could port Adafruit's Arduino library to Raspberry PI C++ by using Gordon Henderson's WiringPi project. And I must say, this library is VERY nice!! I install it on every Raspberry PI I use! So all I would have to do is change any reference from using Wire.h and tell the library to use wiringPi's I2C functionality. This may actually work but not in the time frame for my Capstone project. This needs to be presentable by April 20th or so. That is just before I present for Scholar's Day at BVU.

So, a day later, I decided that it would be wiser to just write my early flight controller programs in python rather than in C++. This was due to the fact that there are already libraries written for the PWM board and example code for the MPU-6050 all written in python. There is also not a library to use the PWM board written in C or C++ so this was the best option. So, rather than rewriting two pre-existing libraries, I just change the language of my flight control program to python for now.

For my Capstone checkpoint next week, I want to solve the ESC power problem. I need to get the PI to spin up each motor in turn. Once I get this done, I need to attach the MPU-6050 orientation sensor. Once I get values from this sensor read into the PI, I want to make a very basic first attempt at a flight control program. If one side is lower than the other, that side spins faster. No fine tuning yet but some response to real world environment.

No comments:

Post a Comment