Difference between revisions of "F15: Quadcopter by Thomas"

From Embedded Systems Learning Academy
Jump to: navigation, search
(PWM)
Line 4: Line 4:
  
 
==Design & Implementation==
 
==Design & Implementation==
 +
 +
 +
 +
== Parts List & Cost ==
 +
 +
 +
{| class="wikitable"
 +
|-
 +
! scope="col"| Qty (Extra)
 +
! scope="col"| Description
 +
! scope="col"| Manufacturer
 +
! scope="col"| Cost
 +
|-
 +
| 4(2)
 +
| [http://hobbyking.com/hobbyking/store/__39708__Afro_ESC_30Amp_Multi_rotor_Motor_Speed_Controller_SimonK_Firmware_.html Afro ESC 30 Amp Speed Controller (SimonK Firmware)]
 +
| Turnigy
 +
| $84.00
 +
|-
 +
| 2
 +
| [http://www.rctigermotor.com/html/2014/Combo_pack_0930/279.html Motors & Propellers Combo]
 +
| T-Motor
 +
| $180.00
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=8992 Turnigy 9X 9Ch Transmitter w/ Module & 8ch Receiver (Mode 2) (v2 Firmware)]
 +
| Turnigy
 +
| $59.99
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/__11927__Turnigy_nano_tech_4000mah_3S_25_50C_Lipo_Pack.html Turnigy nano-tech 4000mAh 3S1P 25-50C Lipo Pack]
 +
| Turnigy
 +
| $26.90
 +
|-
 +
| 2
 +
| [http://www.hobbyking.com/hobbyking/store/__24291__Hobbyking_SK450_Glass_Fiber_Quadcopter_Frame_450mm.html Hobbyking SK450 Glass Fiber Quadcopter Frame 450mm]
 +
| Hobbyking
 +
| $36.00
 +
|-
 +
| 2
 +
| [http://www.hobbyking.com/hobbyking/store/__28221__Extended_Landing_Skid_Set_for_SK450_Quadcopter_Frame.html?gclid=CjwKEAjwxKSoBRCZ5oyy87DimEcSJADiWsvgxdfssov815O5xjkqKCSUPU5z1SwgCpC-q0PNf9XcWBoC9Qnw_wcB Landing Kit Set]
 +
| Hobbyking
 +
| $20.00
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=23140 Hobbyking Quadcopter Power Distribution Board]
 +
| Hobbyking
 +
| $3.39
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/__18987__On_Board_Lipoly_Low_Voltage_Alarm_2s_4s_.html Hobbyking Lipoly Low Voltage Alarm]
 +
| Hobbyking
 +
| $2.15
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/__11736__Turnigy_Battery_Strap_330mm.html Turnigy Battery Strap]
 +
| Hobbyking
 +
| $1.59
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/__15214__Gyro_Flight_Controller_Mounting_Pad_10pcs_bag_.html Mounting Pad]
 +
| Hobbyking
 +
| $1.99
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/__68__PolyMax_3_5mm_Gold_Connectors_10_PAIRS_20PC_.html 3.5mm Bullet Heads]
 +
| Polymax
 +
| $1.83
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/__20440__Turnigy_nano_tech_3000mah_3S_25_50C_Lipo_Pack_US_Warehouse_.html?strSearch=turnigy%203000mah%203s Turnigy 3000mAh 3S1P 30C Lipo Pack]
 +
| Turnigy
 +
| $21.98
 +
|-
 +
| 1
 +
| [http://www.amazon.com/Original-1%7E15cell-Balancer-Ladegerät-Netzteil/dp/B00KPM4GL2/ref=sr_1_2?s=toys-and-games&ie=UTF8&qid=1426711607&sr=1-2&keywords=imax+b6 iMax B6 Battery Charger]
 +
| IMAX
 +
| $33.46
 +
|-
 +
| 1
 +
| [http://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=9043 Hobbyking 2.4Ghz 6ch Tx USB cable]
 +
| Hobbyking
 +
| $2.99
 +
|-
 +
| 1
 +
| [http://www.amazon.com/KEDSUM%C2%AE-Arduino-Wireless-Bluetooth-Transceiver/dp/B0093XAV4U/ref=sr_1_1/184-0364126-4510207?ie=UTF8&qid=1430246099&sr=8-1&keywords=bluetooth+serial+module Arduino Wireless Bluetooth Transceiver Module Slave 4Pin Serial + DuPont Cable]
 +
| KEDSUM
 +
| $9.99
 +
|-
 +
| 1
 +
| [http://www.amazon.com/Digital-Proportional-Channel-Transmitter-Receiver/dp/9269807304/ref=sr_1_1?ie=UTF8&qid=1431459019&sr=8-1&keywords=flysky+fs-t6 FlySky FS-T6 2.4ghz Digital Proportional 6 Channel Transmitter and Receiver System]
 +
| FlySky
 +
| $57.99
 +
|-
 +
|}
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
 +
  
 
===PWM===
 
===PWM===

Revision as of 03:30, 11 September 2015

Abstract

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

Design & Implementation

Parts List & Cost

Qty (Extra) Description Manufacturer Cost
4(2) Afro ESC 30 Amp Speed Controller (SimonK Firmware) Turnigy $84.00
2 Motors & Propellers Combo T-Motor $180.00
1 Turnigy 9X 9Ch Transmitter w/ Module & 8ch Receiver (Mode 2) (v2 Firmware) Turnigy $59.99
1 Turnigy nano-tech 4000mAh 3S1P 25-50C Lipo Pack Turnigy $26.90
2 Hobbyking SK450 Glass Fiber Quadcopter Frame 450mm Hobbyking $36.00
2 Landing Kit Set Hobbyking $20.00
1 Hobbyking Quadcopter Power Distribution Board Hobbyking $3.39
1 Hobbyking Lipoly Low Voltage Alarm Hobbyking $2.15
1 Turnigy Battery Strap Hobbyking $1.59
1 Mounting Pad Hobbyking $1.99
1 3.5mm Bullet Heads Polymax $1.83
1 Turnigy 3000mAh 3S1P 30C Lipo Pack Turnigy $21.98
1 iMax B6 Battery Charger IMAX $33.46
1 Hobbyking 2.4Ghz 6ch Tx USB cable Hobbyking $2.99
1 Arduino Wireless Bluetooth Transceiver Module Slave 4Pin Serial + DuPont Cable KEDSUM $9.99
1 FlySky FS-T6 2.4ghz Digital Proportional 6 Channel Transmitter and Receiver System FlySky $57.99








PWM

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();
    terminal.init(38400);

    float p;
    int num;

    while(1){

        printf("NO=");
        scanf("%d",&num);
        printf("pwm percent=");
        scanf("%f", &p);
			
        switch(num){

            case 1:
                servo1.set(p);
                break;

            case 2:
                servo2.set(p);
                break;

            case 3:
                servo3.set(p);
                break;

            case 4:
                servo4.set(p);
                break;

            default:
                return;
        }
    }
}


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();


        while(1)
	{
              

                //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
		servo3.set(pServ3);
                #endif


                #ifdef X_AXIS_ACTIVE
		servo2.set(pServ2);
		servo4.set(pServ4);
                #endif
        }



}

The picture of the SJdrone Thomas quad SJdrone.jpg

Conclusion

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