F15: Quadcopter by Thomas

From Embedded Systems Learning Academy
Revision as of 16:17, 4 October 2015 by Proj user1 (talk | contribs) (Physical design)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


The goal of this project is try to implement the basic function of a drone, fly and controlling the direction by remote control.

Parts List & Cost

Item# Part Desciption Manufacturer Qty Cost
1 SJ One Board 1 $80.00
2 NEEWER® HJ450 4-Axis Frame 1 $15.99
3 Afro ESC 20Amp Multi-rotor Motor Speed Controller 4 $83.96
4 Spektrum 5520 DX5e DSMX 5 Channel TX/RX 1 $59.99
5 AR400 4-Channel DSMX Aircraft Receiver 1 $29.99
6 Sunnysky X2212-13 980KV Brushless Motor 4 $61.99
7 Mpu-9250 Gyro Compass Acceleration Magnetic Field Sensor 1 $11.99
8 Venom 30C 3S 3200mAh 11.1V 1 $41.72
9 Andoer Anti-vibration Plate Shock Absorber Set 1 $6.98
10 Kyosho Z8006 Zeal Vibration Absorption Sheet 1 $14.94
11 NEEWER® High Elastic Anti-Vibration 4 $4.17
12 Andoer Carbon Fiber 10x4.5" 1045 CW CCW Propeller 4 $13.99
13 Quadcopter Power Distribution Board XT60 XT-60 20a Quad Mutlicopter 3.5mm 1 $10.29
TOTAL $435.43

Design & Implementation

Physical design

The quad copter need MPU-9250 to caculate the positon, but there are a lot of vibration from the frame. Therefore, we have to use some physical design to decrease the vibration that will affect the sensor. I put the sensor in the Andoer Anti-vibration Plate Shock Absorber Set and wrap the sensor by Kyosho Z8006 Zeal Vibration Absorption Sheet.

Here shows the result. We can see the sensor was warped by the Kyosho Z8006 Zeal Vibration Absorption Sheet.

Thomas quad sensor design.jpg


The four motor on the drone is controlled by the PWM (Pulse Width Modulation). SJSUone board already gave us a good library to use, so we just have to set the frequency and pin number at the beginning of the code.

The example of using the library.

#include "lpc_pwm.hpp"
#include "uart0.hpp"
#include "stdio.h"

#define PWM_FREQ 500

void motor_test()

    PWM servo1(PWM::pwm1, PWM_FREQ);
    PWM servo2(PWM::pwm2, PWM_FREQ);
    PWM servo3(PWM::pwm3, PWM_FREQ);
    PWM servo4(PWM::pwm4, PWM_FREQ);

    Uart0& terminal = Uart0::getInstance();

    float p;
    int num;


        printf("pwm percent=");
        scanf("%f", &p);

            case 1:

            case 2:

            case 3:

            case 4:


Here is a diagram shows the output of the PWM. PWM_FREQ variable from the previous sample code can control the period and p variable can control the duration.

Thomas quad PWM diagram..PNG

For a drone, a shorter period of PWM can have better performance, more stable, but the range of the controlling will be smaller if we decrease the period. For example, my system is using 500 Hz PWM and my control range will be about 53% to 100% because the motor will start to rotate at 53%. However, if we change the frequency to 1000 Hz, the motor will start to rotate at 90%, so the the control range will be 90% to 100%. Therefore, we have to find the balance of the performance and the control range.

For controlling the motor, we have to set PWM frequency in every certain period very precisely, so delay function can not satisfy our need. Fortunately, FreeRTOS have the timer interrupt API that can execute the code in period. Here we are talking about the control rate that is different from the PWM rate. The control rate should lower than the PWM rate and the data rate from sensor. For my experiment, 50 Hz is enough to fly but hard to control it. If you want to control it, my recommendation is higher than the 150 Hz.

Here is part of my code.

void motor_control(void *p)

        TickType_t xLastWakeTime;
        int period_ms=2;// control rate (500 MHz)
        const TickType_t xFrequency = MS_TO_TICK_RATE(period_ms);
        PWM servo1(PWM::pwm1, 500);
	PWM servo2(PWM::pwm2, 500);
	PWM servo3(PWM::pwm3, 500);
	PWM servo4(PWM::pwm4, 500);

        xLastWakeTime = xTaskGetTickCount();


                //PID control code is in here

		vTaskDelayUntil( &xLastWakeTime, xFrequency ); //every 2ms the system will execute the code below

                #ifdef Y_AXIS_ACTIVE
		servo1.set(pServ1);  //pServ1 will be the % of output for the next period

                #ifdef X_AXIS_ACTIVE


The picture of the SJdrone Thomas quad SJdrone.jpg


Project Video

Upload a video of your project and post the link here.

first lunch of the SJSU drone https://youtu.be/lzpCwFyz_Yk

first fly of the SJSU drone https://youtu.be/GKQJtUIinW8

second fly of the SJSU drone https://youtu.be/MFJ1-ZD47U0

third fly of the SJSU drone https://youtu.be/MBFmyweXbKY

final release of the SJSU drone https://youtu.be/Tv8Bm9wMOkI

final release of the SJSU drone 1 https://youtu.be/xEOyXph9FBg

final release of the SJSU drone 2 https://youtu.be/PvUbFLxbC-s