仿真毕设分享 esp8266四轴飞行器

简介

Hi,大家好,今天向大家介绍一个学长做的单片机项目

毕业设计 esp8266四轴飞行器

大家可用于 课程设计 或 毕业设计

🔥 项目分享:
https://gitee.com/feifei1122/simulation-project

一、电路设计

硬件组成:

  • Arduini Nan
  • ESP8266
  • MPU6050 模块
  • 有刷电机
  • 螺旋桨
  • 电池包
  • Si2302场效应管
  • 无人机架

ESP8266模块

为了与无人机通信,我们需要蓝牙或WIFI连接,所以我们使用ESP8266 Wi-Fi模块,因为它有内置的Wi-Fi,我们可以使用它进行通信。

ESP8266开源、互动、可编程、低成本、简单、智能、最低成本的Wi-Fi硬件。

至于无人机的飞行范围。测试已经得到了范围大约是70米,使用三星手机充当WiFi热点和远程控制器。

MPU6050

MPU6050 IMU,一个低成本的设备,包含陀螺仪和加速计。

我们将使用MPU-6050和ESP8266模块来做一个无人机。

二、效果图

三、部分代码

    
​    #include
​    #include 
​    #include 
​    WiFiUDP UDP;char packet[4];//IPAddress local_IP(192, 168, 203, 158);//IPAddress gateway(192, 168, 1, 158);//IPAddress subnet(255, 255, 0, 0);//_________________________________________//  int ESCout_1 ,ESCout_2 ,ESCout_3 ,ESCout_4;int input_PITCH = 50;int input_ROLL = 50;int input_YAW = 50;volatile int input_THROTTLE = 0;int Mode = 0;
​    
​    boolean wall_car_init = false;
​    boolean set_motor_const_speed = false;int8_t target_axis=0;int8_t target_dirr=0;
​    boolean wheal_state = false;uint8_t pwm_stops;
    int arr[] = {20,10,20,10};
    volatile int order[] = {0,0,0,0}; //volatile key
    int temp_arr[] = {0,0,0,0};
    int pulldown_time_temp[] = {0,0,0,0,0};
    int pulldown_time[] = {0,0,0,0,0};
    volatile int pulldown_time_temp_loop[] = {0,0,0,0,0}; //volatile key
    uint8_t pin[] = {14,12,13,15};
    int i,j,temp_i,temp;
    boolean orderState1,orderState2,orderState3,orderState4,Timer_Init;
    
    int16_t gyro_x, gyro_y, gyro_z, acc_x, acc_y, acc_z, temperature, acc_total_vector;
    float angle_pitch, angle_roll,angle_yaw,prev_roll,prev_pitch,prev_yaw;
    boolean set_gyro_angles;
    float angle_roll_acc, angle_pitch_acc;
    float angle_pitch_output, angle_roll_output, angle_yaw_output;
    long Time, timePrev;
    float elapsedTime,P_factor;
    float acceleration_x,acceleration_y,acceleration_z;
    long gyro_x_cal, gyro_y_cal, gyro_z_cal;
    float pitch_PID,roll_PID,yaw_PID;
    float roll_error, roll_previous_error, pitch_error, pitch_previous_error, yaw_error, yaw_previous_error;
    float roll_pid_p, roll_pid_d, roll_pid_i, pitch_pid_p, pitch_pid_i, pitch_pid_d, yaw_pid_p, yaw_pid_i, yaw_pid_d;
    float roll_desired_angle, pitch_desired_angle, yaw_desired_angle; 
    double twoX_kp=5;      //5
    double twoX_ki=0.003;   //0.003   
    double twoX_kd=1.4;     //1.4
    double yaw_kp=8;      //5
    double yaw_ki=0;  //0.005
    double yaw_kd=4;      //2.8


​    
​    
​    void ICACHE_RAM_ATTR PWM_callback() {switch (pwm_stops){case 0:
​          pulldown_time_temp[0] = pulldown_time_temp_loop[0];
​          pulldown_time_temp[1] = pulldown_time_temp_loop[1];
​          pulldown_time_temp[2] = pulldown_time_temp_loop[2];
​          pulldown_time_temp[3] = pulldown_time_temp_loop[3];
​          pulldown_time_temp[4] = pulldown_time_temp_loop[4];
​          pwm_stops = 1;if(input_THROTTLE!=0){GPOS = (1 << 14);GPOS = (1 << 12);GPOS = (1 << 15);GPOS = (1 << 13);}timer1_write(80*pulldown_time_temp[0]);break;case 1:
​          pwm_stops = 2;
​          GPOC = (1 << pin[order[0]]);timer1_write(80*pulldown_time_temp[1]);break;case 2:
​          pwm_stops = 3;
​          GPOC = (1 << pin[order[1]]);timer1_write(80*pulldown_time_temp[2]);break;case 3:
​          pwm_stops = 4;
​          GPOC = (1 << pin[order[2]]);timer1_write(80*pulldown_time_temp[3]);break;case 4:
​          pwm_stops = 0;
​          GPOC = (1 << pin[order[3]]);timer1_write(80*pulldown_time_temp[4]);break;}}


🔥 项目分享:
https://gitee.com/feifei1122/simulation-project

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值