Articles

Affichage des articles du 2017

Arduino flight controller

I found amazing project with many videos to build a quadcopter controlled using arduino uno. I am now analyzing the arduino code to understand how it works. I already found some interesting ideas : Loop frequency is 250hz. It means MPU6050 is read 250 times in a second and esc are updated 250 times too  It is a higher frequency than rasberrry zero can produce MPU6050 code to compute pitch and roll is different than mine. It seems to use acceleration rather than angle to compute pitch and roll. And it does not use dplf to reduce noise. I am surprised. It need to be tested. Battery voltage is read and used to increase esc pulses when voltage drops. It permits to stabilize quadcopter performances. Because when voltage decrease, motor rotation decrease too. Good idea. Esc pulses don't use the arduino servo library. They are generated manually using raw commands (pulse high for 1000-2000 us then low for a total cycle of 4000 us). So it needs a loop frequency of exactly 250 hz....

Arduino Test

Image
After few days thinking why my quadcopter python algorithm does not work during real test, I finally suspect the pwm pigpio libray does not do the job. So I decided to test my algorithm using Arduino beacuse it has 4 hardware pwm pins. I bought Arduino Uno. So I started to rewrite my python algorithm in C/C++. During rewiting my code in C/C++, I feel to go back 20 years ago...in the 1990s....Use basic functions, keep care low usage memory... Using Arduino is very very different from Raspberry, Logs are basics, you must use serial communication using an usb cable. It is not so easy....But I finally ended my code. MPU6050 code is finished. I read it and compute roll/pitch. PID and speeds motors are compute too. Now I have to test my code again as I did with Raspberry I have not yet tested pwm harware pins. I should have do this first but I got a basic problem. In fact, my usb cable between my computer and my arduino/quadcopter is too short ! So I have to w...

Mini quadcopter Eachine e55

Image
Few weeks ago I got an mini quadcopter Eachine e55 for the Father Day. After few flies, I bought 5 batteries on banggood. Now i can play with my quadcopter for 1 hour. It is fine. I use my smartphone to control it over wifi. It is easiest to control than the rc control (I am still a beginner) But two days ago I broke a motor... I found no help on the web how to repair it. So I decided to disassemble myself my Eachine e55. And I made my first youtube video to explain how to :  Some pictures Now I am waiting my motor order from banggood. I will receive it at the end of july

Quadcopter - What is wrong ?

Last 2 days I made few tests with motors ON All tests confirm my previous vitual tests . But reality is not virtual and the quadcopter does not do what I thought ! As in my    previous vitual tests , fo r the first test, I tilted  my platform  in front and start the quadcopter with motors ON. I  thought the lower side will raise to go and stay in horizontal position. In fact, the lower side raised as expected but it did not stop to raise when it got horizontal position. It raised again and then the quadcopter turn over the other side.... Considering another little problem which is sometimes at startup only 3 of 4 motors starts normally. I suspect pigpio library not to do the job. Is this libray able to send PWM signal for all 4 motors ? Just remimber this is not a hardware PWM signal.... So today,.I don't know where to search...  I am a little desperate...

Indoor Test - Pitch and Roll computation

Image
I have written my first algorithm to compute pitch and roll. So I made few tests to check it. Pitch shows if quadcopter tilt front (pitch is positive) or tilt back (pitch is negative) Roll shows if quadcopter tilt left (roll is positive) or tilt right (roll is negative) Determining pitch and roll is very important to control motors and get a stable flying quadcopter. For example, if quadcopter tilt front pitch will be positive. So, to get a stable quadcopter, we will need to increase front motors speed and decrease back motors speeds To do this, I found help on this page . It use acceleration in the computation.to correct read values from the sensor MPU-6050. All tests were virtual test with motors OFF For the first test, I tilted my platform in front, then I raise it to horizontal and then let it down Here is values read and used to compute pitch qay quadcopter acceleration Y read from sensor MPU-6050 qrx quadcopter ...

Indoor Test

Image
After my first test outside which led to the breakage of 2 propellers, I decided to do tests inside. For that, I tied the quadcopter on a wooden board. Two feets are fixed and the others two are free. Thus, by tilting the board, I hope that algorithm will compensate the inclination and adjust the motors so that the quadcopter is stable horizontally Here is a quick diagram

Raspbian - How to connect to multiple wifi networks

Today, I have configured my raspberry to connect at boot to the HotSpot Wifi of my phone if it is available. If not, It will connect to my home wifi To do this, you need to edit the wpa_supplicant.conf file: sudo nano /etc/wpa_supplicant/wpa_supplicant.conf And you must add a second block "network": country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="my home network" psk="password" scan_ssid=1 priority=0 id_str="Home" } network={ ssid="my phone network" psk="mot de passe" scan_ssid=1 priority=1 id_str="Phone" } You must add in each block : Scan_ssid = 1 to search the wifi network Priority = 1 to select by default the network that has the highest priority Id_str = "xxx" to give a name to the network (may be optional?) Now when I am outside, I can conn...

I2C Bus speed

It does not look like anything but by changing the speed of the I2C bus, the data reading of the MPU-6050 is done in less than 1 ms instead of 2 ms To change the speed of the I2C bus, you need to edit the file /boot/config.txt and add this line  : dtparam=i2c_arm_baudrate=400000 With this, I manage to run the control algorithm of my Quadcopter in less than 7 ms. I can thus guarantee a frequency of 100 Hz (100 loops per second) As a reminder, at each loop, I read the data of the MPU-6050, I carry out all calculations and adjust accordingly the speed of the 4 engines.

First test outdoor and first breakage !

Image
Yesterday morning, I did my first flight test out. 2 problems: My phone LG3 loses the wifi hotspotan then I can no longer control the raspberry Some propellers randomly do not start or not at the same speed as the others This morning, try again To correct my previous problems, I tested with my wife's Honor 5C phone. No more loss of wifi ;-) Instead of plugging the raspberry on the beak of an ESC, I plugged the raspberry on an external battery. No more problem starting the propellers. But the tests were not very conclusive ... The QuadCopter has indeed raised too much on one side. The other side did not stand up. So he tipped over and flipped over. This resulted in the breakage of 2 propellers. I still struggled to interpret the results of the logs because I do not know which side it rocked. In the future, I will have to film the flight so that I can analyze it later Here are some graphs of my simulations First test : I lean the quadcopter forward by 30 degrees...

QuadCopter using Raspberry Zero W

Image
Today I have mounted my Raspberry Zero W on my QuadCopter If it works it will lighten the total weight of the Quadcopter because the Zero weighs only 9 grams! On the other hand, Raspberry Zero is much less powerful than my Raspberry 2 ... The big problem was ServoBlaster Like RPIO, this library did not want to run on a Raspberry Zero!?! So, I tested pigpio and miracle, it works! Then, I see the pigiod daemon consumes a little too much cpu ... Consumption 7.1% .... Gloups .... I thought it was hardware. I'll analyze that later Here is my python code : import time import pigpio SERVO = 4 pi = pigpio . pi() # Connect to local Pi. print ( "start" ) pi . set_PWM_frequency(SERVO, 50 ) pi . set_servo_pulsewidth(SERVO, 1000 ) # Minimum throttle. print (pi . get_PWM_frequency( 17 )) raw_input ( "Press Enter to 1100..." ) pi . set_servo_pulsewidth(SERVO, 1200 ) # Minimum throttle. raw_input ( "Press Enter to end..." ) pi . s...

Adjustment of motors

Image
I connected the 4 white ESC control wires to servos 0 to 3 (pins 7,11,12 and 13) and the black wires to ground (pin 9): Servo number GPIO number Pin in P1 header Moteur 0 4 P1-7 M1 1 17 P1-11 M2 2 18 P1-12 M3 3 21/27 P1-13 M4 Then I adjust the direction of rotation of the motors as below: In order for the quadcopter to be stable and not to turn on itself, the M1 / M3 motors must rotate in the same direction and M2 / M4 in the opposite direction. If a motor does not rotate in the desired direction, swap 2 of the 3 wires

Building the quadcopter

Image
I start to build my quadcopter The frame is assembled and the motors are fixed I calibrated the 4 ESCs and tested the 4 motors one by one (without the propellers of course). All is OK I still have to buy rilsan (cable ties) to fix the ESC on the arms My Quadcopter name is  ROSETTA ;-) Here is my ESC calibration procedure : Disconnect the battery sudo  /usr/local/sbin/servod --cycle-time=20000us --step-size=10us --min=1000us --max=2000us Connect the motor to ESC Send a pulse max value pi@raspberrypi:~ $ echo 1=200 >/dev/servoblaster Connect the ESC to Raspberry (white wire on gpio on servo1, black wire on gpio GND - Do not use the red wire) Connect the battery Wait Beep Beep Send a pulse min value pi@raspberrypi:~ $ echo 1=100 >/dev/servoblaster Wait Beep Beep Beep (battery 3S = 3 Beeps)  Wait a long Beep. This means calibration is ok ! pi@raspberrypi:~ $ echo 1=0 >/dev/servoblaster You will get a beep every 2 seconds (invalid sign...

Motor one tow three four go !

Image
I do it. I finally managed to start my 1st motor! On top: 2 wires to the LIPO battery On left: the 3 control wires of the ESC. Black to mass and white on a pine GPIO of raspberry (red is not used)  I use  ServoBlaster to control l'ESC Parameters are : /usr/local/sbin/servod --cycle-time=20000us --step-size=10us --min=1000us --max=2000us What you must know : a pulse of 1ms = motor at 0% : echo 1=100 >/dev/servoblaster a pulse of 2ms = motor full at 100% : echo 1=200 >/dev/servoblaster I created a python function to drive my motor : def servo(servo, val): servoStr ="%u=%u\n" % (servo, val) with open("/dev/servoblaster", "wb") as f: f.write(servoStr) Processing time is very good (1ms) PS: I was unable to run RPIO even on my Raspberry Pi Zero W. So, I drop RPIO because it is too hardware dependent. ServoBlaster seems to work properly

RPIO = Rest In Peace

I wanted to use RPIO library to drive motors I did however some tests of the python library RPIO. I was confident ... In fact, I have a 2.0 beta version unknown (I don't remember whre i find it...) and it does not work well. Unable to address certain pins, the output is not in OUT .... In short it is a real problem. As a reminder, this library is essential to drive the motors. It allows to make PWM control in hardware without soliciting the cpu. PS: After a lot of search on Google last night, it seems that the RPIO library is not compatible with all the models of Raspberry. In any case, it does not work on my Raspberry Pi 2. I will test other libraries like ServoBlaster or PigPio PPS: Another solution, less headache, buy an add-on card that manages the PWM in hardware. For example, this  Adafruit 16-Channel  PWM

Building a Quadcopter using Raspberry Pi

Image
Building a Quadcopter using Raspberry Pi... The idea came to me during my holidays by reading an article by Andy Baker in the MagPI newspaper (numbers 19 and 20) On reading the article, a quadcopter appeared to me very simple to build. And then, according to my research, I realized nevertheless that there are a lot of knowledge to know and that it will be quite complicated .. . So I bought the material on ebay: The F450 frame The 4 motors The 4 propellers The 4 ESCs The LIPO 3S battery The MPU6050 (gyroscope / accelerometer sensor) F450 kit The MPU6050 (gyroscope / accelerometer sensor) For the flight controller part, I use a Raspberry Pi 2 that I already have. As passionate computer scientist, the idea is to program the Raspberry to drive the engines according to the MPU6050 sensor which will provide me informations on tilt and acceleration. So, I will not want to use the CC3D flight controller provided in the kit. For the remote control, ...