Skip to content

Commit

Permalink
add frame
Browse files Browse the repository at this point in the history
  • Loading branch information
DanieleVeri committed Jan 1, 2024
1 parent 2afdd3b commit 8e4d9d8
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 12 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# Arduino quadcopter
A simple quadcopter filght controller designed to work in angle control mode ([diagram](https://docs.px4.io/v1.12/assets/img/mc_control_arch.21116ef0.jpg)).
All parameters are grouped in `config.h`.
Switch `OPERATING_MODE` to perform ESC calibration and IMU calibration.
Switch `DEBUG` to visualize print messages in the serial monitor.
The control loop frequency is about 80Hz.

## Hardware
## Software requirements
Arduino libraries:
- MPU9250==0.4.8
- AutoPID==1.0.3

## Hardware requirements
- Board: Arduino Mega 2560
- Imu: MPU 9250
- Receiver: Flysky FS-IA6
- Motor/ESC: A2212 1000KV Brushless Motor 30A ESC
- Propeller: 1045
- Rangefinder: HC-SR04
- Battery: LiPo 2S 30C EC2 or LiPo 3S 35C XT60
- Battery: LiPo 3S 35C XT60
- DC/DC stepdown: LM7805
- 30A fuse

## Requirements
- MPU9250==0.4.8
- AutoPID==1.0.3
## Frame
- 4x motor.stl
- 4x holder.stl
- 4x hollow alluminium rod 10x10x130 mm (to link motor and holder)
- 1x plastic disk diameter ~220 mm (the base where to anchor holders with 3M bolts)
- 1x cover.stl

![img](frame/top.jpg)
![img](frame/bottom.jpg)
10 changes: 7 additions & 3 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#define BANGBANG 300
#define TIMESTEP 10

// Low pass filter
#define LPFD 0.2

// Pid config
#define ROLL_PID_KP 1.1
#define ROLL_PID_KI 0
Expand All @@ -46,6 +43,13 @@
#define YAW_RATE_PID_KI 0
#define YAW_RATE_PID_KD 0

// Angular rate low pass filter coefficient
#define LPFD 0.2

// Smooth fall
#define SMOOTH_FALL_DIST 10
#define SMOOTH_FALL_PWM 1350

// Motor pins
#define PIN_MOTOR_0 6
#define PIN_MOTOR_1 3
Expand Down
9 changes: 5 additions & 4 deletions flight_control.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "Servo.h"
#include "Arduino.h"
#include "AutoPID.h"
#include "flight_control.h"
Expand Down Expand Up @@ -81,11 +82,11 @@ void control_loop() {
PID_roll_rate.run();
PID_pitch_rate.run();
PID_yaw_rate.run();
// Slow fall from higher than 10cm
if (ground_dist > 10 && ground_dist < 400)
throttle = max(throttle, 1300);
// Prevent free fall from more than 10cm
if (ground_dist > SMOOTH_FALL_DIST && ground_dist < 400)
throttle = max(throttle, SMOOTH_FALL_PWM);
// Thrust correction by attitude
throttle = 1000 + ((float)(throttle - 1000)) / (cos(angles.roll * DEG_TO_RAD) * cos(angles.pitch * DEG_TO_RAD));
throttle = MIN_PULSE_LENGTH + ((float)(throttle - MIN_PULSE_LENGTH)) / (cos(angles.roll * DEG_TO_RAD) * cos(angles.pitch * DEG_TO_RAD));
// Mixer
mixer_output[0] = throttle + (rates_output.roll) + (rates_output.pitch) + rates_output.yaw;
mixer_output[1] = throttle - (rates_output.roll) + (rates_output.pitch) - rates_output.yaw;
Expand Down
Binary file added frame/bottom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frame/cover.stl
Binary file not shown.
Binary file added frame/holder.stl
Binary file not shown.
Binary file added frame/motor.stl
Binary file not shown.
Binary file added frame/top.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8e4d9d8

Please sign in to comment.