Difference between revisions of "F15: Quadcopter by Thomas"

From Embedded Systems Learning Academy
Jump to: navigation, search
Line 1: Line 1:
 +
 +
==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==
 +
 +
===PWM===
 +
The four motor on the done is controlled by the PWM (Pulse Width Modulation). The SJSUone board already gave us a good library to use, so we just have to set the frequency and pin at the beginning of the code.
 +
 +
 +
The example of using the library.
 +
<source lang="c">
 +
 +
#define PWM_FREQ 500
 +
#include "lpc_pwm.hpp"
 +
#include "uart0.hpp"
 +
#include "stdio.h"
 +
 +
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;
 +
        }
 +
    }
 +
}
 +
 +
 +
</source>
  
  
Line 4: Line 70:
  
 
The picture of the SJdrone
 
The picture of the SJdrone
[[File:Thomas quad SJdrone.jpg]]
+
[[File:Thomas quad SJdrone.jpg|200px]]

Revision as of 18:49, 2 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

PWM

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


The example of using the library.

#define PWM_FREQ 500
#include "lpc_pwm.hpp"
#include "uart0.hpp"
#include "stdio.h"

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;
        }
    }
}



The picture of the SJdrone Thomas quad SJdrone.jpg