New (2023)

The updated version of the peregrine UAV uses a singular RP2040 chip with the CYW43 network card running FreeRTOS

PCB Design

Master Map

Firmware Modules
Software
EDFs
Servos
Motor Controllers
Sensors
Power Sources
Public Methods
Servos
update_edf_power
EDFs

while (True)

xSemaphoreTake(edf_lock)

while (edf_needs_updated())

if (edf1_power != edf1_target_power)

actuator_control_interface_set_tvc_x(double _x)

actuator_control_interface_set_tvc_y(double _y)

actuator_control_interface_calibrate_tvc_x_min(uint8_t _deg)

actuator_control_interface_calibrate_tvc_x_max(uint8_t _deg)

else

edf1_power -= edf1_rate

if(edf1_power > edf1_target_power)

edf1_power = edf1_target_power

if(edf1_power < edf1_target_power)

edf1_power += edf1_rate

if (edf2_power != edf2_target_power)

if (edf3_power != edf3_target_power)

if (edf4_power != edf4_target_power)

Note: this method will simply return if any of the edf power(s) don't equal their target value

This is being abstracted to a method for code readability

if(edf1_power < edf1_target_power)

edf1_power = edf1_target_power

set_pwm

actuator_control_interface_set_aileron_l(double _l)

actuator_control_interface_set_aileron_r(double _r)

actuator_control_interface_calibrate_tvc_y_min(uint8_t _deg)

actuator_control_interface_calibrate_tvc_y_max(uint8_t _deg)

actuator_control_interface_calibrate_aileron_l_min(uint8_t _deg)

actuator_control_interface_calibrate_aileron_l_max(uint8_t _deg)

actuator_control_interface_calibrate_aileron_r_min(uint8_t _deg)

actuator_control_interface_calibrate_aileron_r_max(uint8_t _deg)

actuator_control_interface_soft_set_edf_1(uint8_t power, uint8_t rate)

actuator_control_interface_soft_set_edf_2(uint8_t power, uint8_t rate)

actuator_control_interface_soft_set_edf_3(uint8_t power, uint8_t rate)

actuator_control_interface_soft_set_edf_4(uint8_t power, uint8_t rate)

actuator_control_interface_set_edf_1(uint8_t power)

actuator_control_interface_set_edf_2(uint8_t power)

actuator_control_interface_set_edf_3(uint8_t power)

actuator_control_interface_set_edf_4(uint8_t power)

Functional Requirements

  • Flight Data
    • Flight stage
    • Full system health status
      • Operational
      • Minor error
      • Fatal error
  • Network Status
    • View Network Connection Status
      • Connected
      • Not Connected
    • View time since last network packet was received
      • Example 20ms
  • Peripheral Data
    • Note:
      • Health status will be broken down into:
        • Operational
        • Disconnected
        • Faulty
    • View Accelorometer Data
      • Health status
      • Activation state
      • x,y,z
    • View Gyroscope Data
      • Health status
      • Activation state
      • x,y,z
    • View Barometric Pressure Data
      • Health status
      • Activation state
      • altitude
    • View Magnetometer Data
      • Health status
      • Activation state
      • heading
    • View Ultrasonic Sensor Data
      • Health status
      • Activation state
      • distance in mm
  • Actuator Data
    • View Motor data x4
      • Health status
      • Power percentage
    • View servo data x4
      • Health status
      • Angle
  • System Data
    • System needs to be capable of uniquely identifying connection
    • System needs to be capable of verifying firmware version

Transferred Data

This contains information pertaining to what data is actually transmitted and received to and from the UAV over the wireless connection.


Estimated Total Unique Messages: 46

Received Data (from the UAV)

logging

  • debug
  • info
  • error
  • fatal

peripheral

managed by AACS > Sensor Control Interface

  • accelorometer:
    • x
    • y
    • z
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • gyroscope:
    • x
    • y
    • z
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • altimeter
    • altitude
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • magnetometer
    • heading
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated
  • ultrasonic
    • distance
    • status : operational, faulty, disconnected
    • activation state: activated, deactivated

actuator

managed by AACS > Actuator Control Interface

  • motor 1
    • status : operational, faulty, disconnected
    • power percent
  • motor 2
    • status : operational, faulty, disconnected
    • power percent
  • motor 3
    • status : operational, faulty, disconnected
    • power percent
  • motor 4
    • status : operational, faulty, disconnected
    • power percent
  • servo 1
    • status : operational, faulty, disconnected
    • angle
  • servo 2
    • status : operational, faulty, disconnected
    • angle
  • servo 3
    • status : operational, faulty, disconnected
    • angle
  • servo 4
    • status : operational, faulty, disconnected
    • angle

flight data

managed by AACS > Master Control Interface

  • flight stage
  • overall system health
  • ready to enter launch stage
  • ready to enter target acquisition stage
  • ready to enter stealth surveillance stage
  • ready to enter vehicle extraction stage
  • ready to enter landing stage

Transmitted Data (to the UAV)

UI Design

Circular transclusion detected: projects/project-peregrine/hardware

System Architecture

Circular transclusion detected: projects/project-peregrine/hardware

MPU6050

Aileron R

TVC X

TVC Y

Aileron L

BMP280

HMC5883L

SSD1306

EEPROM

Advanced Avionics Control System

Processor : RP2040 (Raspberry Pi Pico W)
OS : FreeRTOS


Sensor Control Interface

Circular transclusion detected: projects/project-peregrine/hardware

Variables

There are going to be a set of static variables that contain all of the sensor data. These variables are going to be protected using mutexes since they will be continuously updated via the internal sensor reading task and continuously read through the various “public” methods.

I need to do some research on what formats would be good for using the numbers in (i.e. should accelerator data be a double between 1 and -1 or is it better represented as an unsigned or signed int?)

C2 Communication

Documentation for what all the C2 server needs can be found here


UML

classDiagram
	class sensor_control_interface{
		- double accelorometer_x;
		- double accelorometer_y;
		- double accelorometer_z;
		- double gyroscope_x;
		- double gyroscop_y;
		- double gyroscop_z;
		- double altitude;
		- double heading;
		- double us_distance;

		- SemaphoreHandle_t mpu_mutex;
		- SemaphoreHandle_t bmp_mutex;
		- SemaphoreHandle_t qmc_mutex;
		- SemaphoreHandle_t hcsr_mutex;

		- int sensor_error_count;
		+ sensor_control_interface_init(UBaseType_t sensor_task_priority): int
		+ sensor_control_interface_get_accelorometer_x(): double
		+ sensor_control_interface_get_accelorometer_y(): double
		+ sensor_control_interface_get_accelorometer_z(): double
		+ sensor_control_interface_set_accelorometer_x(double _x): void
		+ sensor_control_interface_set_accelorometer_y(double _x): void
		+ sensor_control_interface_set_accelorometer_z(double _z): void
		+ sensor_control_interface_accelerometer_activate(): int
		+ sensor_control_interface_accelerometer_deactivate(): int
		+ sensor_control_interface_get_gyroscope_x(): double
		+ sensor_control_interface_get_gyroscope_y(): double
		+ sensor_control_interface_get_gyroscope_z(): double
		+ sensor_control_interface_set_gyroscope_x(double _x): void
		+ sensor_control_interface_set_gyroscope_y(double _x): void
		+ sensor_control_interface_set_gyroscope_z(double _z): void
		+ sensor_control_interface_gyroscope_activate(): int
		+ sensor_control_interface_gyroscope_deactivate(): int
		+ sensor_control_interface_get_altimeter_altitude(): double
		+ sensor_control_interface_set_altimeter_altitude(double _altitude): int
		+ sensor_control_interface_altimeter_activate(): int
		+ sensor_control_interface_altimeter_deactivate(): int
		+ sensor_control_interface_get_compass_heading(): double
		+ sensor_control_interface_set_compass_heading(double _heading): int
		+ sensor_control_interface_compass_activate(): int
		+ sensor_control_interface_compass_deactivate(): int
		+ sensor_control_interface_get_ultrasonic_distance(): double
		+ sensor_control_interface_set_ultrasonic_distance(double _distance): int
		+ sensor_control_interface_ultrasonic_activate(): int
		+ sensor_control_interface_ultrasonic_deactivate(): int
		+ sensor_control_interface_reset_mpu_6050(): int
		+ sensor_control_interface_reset_bmp_280(): int
		+ sensor_control_interface_reset_qmc _5883l(): int
		+ sensor_control_interface_reset_hc_sr04(): int
		+ sensor_control_interface_task(): int
	}

Public Methods

General

sensor_control_interface_init

Accelerometer

Getters:
sensor_control_interface_get_accelerometer_x
sensor_control_interface_get_accelerometer_y
sensor_control_interface_get_accelerometer_z
Setters:
sensor_control_interface_set_accelerometer_x
sensor_control_interface_set_accelerometer_y
sensor_control_interface_set_accelerometer_z
Activators:
sensor_control_interface_accelerometer_activate
sensor_control_interface_accelerometer_deactivate

Gyroscope

Getters:
sensor_control_interface_get_gyroscope_x
sensor_control_interface_get_gyroscope_y
sensor_control_interface_get_gyroscope_z
Setters:
sensor_control_interface_set_gyroscope_x
sensor_control_interface_set_gyroscope_y
sensor_control_interface_set_gyroscope_z
Activators:
sensor_control_interface_gyroscope_activate
sensor_control_interface_gyroscope_deactivate

Altimeter

Getters:
sensor_control_interface_get_altimeter_altitude
Setters:
sensor_control_interface_set_altimeter_altitude
Activators:
sensor_control_interface_altimeter_activate
sensor_control_interface_altimeter_deactivate

Compass

Getters:
sensor_control_interface_get_compass_heading
Setters:
sensor_control_interface_set_compass_heading
Activators:
sensor_control_interface_compass_activate
sensor_control_interface_compass_deactivate

Ultrasonic

Getters:
sensor_control_interface_get_ultrasonic_distance
Setters:
sensor_control_interface_set_ultrasonic_distance
Activators:
sensor_control_interface_ultrasonic_activate
sensor_control_interface_ultrasonic_deactivate

Internal Methods

Threading

sensor_control_interface_task

Error Handling

sensor_control_interface_reset_mpu_6050
sensor_control_interface_reset_bmp_280
sensor_control_interface_reset_qmc _5883l
sensor_control_interface_reset_hc_sr04

Actuator Control Interface

Circular transclusion detected: projects/project-peregrine/hardware

Diagrams

int calculatePowerChange(int currentPower, int targetPower, int rateOfChange) {
    // Ensure rateOfChange is within the valid range (1-100)
    rateOfChange = max(1, min(100, rateOfChange));
 
    // Calculate the remaining difference between currentPower and targetPower
    int remainingDifference = targetPower - currentPower;
 
    // Calculate the adder/subtractor for the given rate of change
    int change = (remainingDifference * rateOfChange) / 100;
 
    // Ensure a minimum change to prevent very slow transitions
    change = max(change, MIN_CHANGE);  // Adjust MIN_CHANGE as needed
 
    return change;
}
 

C2 Communication

Documentation for what all the C2 server needs can be found here

Master Control Interface

The master_control_interface is responsible for high level control over the UAV.

C2 Communication

Documentation for what all the C2 server needs can be found here

EDF 1

EDF 2

EDF 3

ARM-M0+

EDF 4

37v

7.4v

3.3v linear regulator

ESC

ESC

ESC

ESC

Wireless ConnectionI2CI2CI2C
Link to original

Sensors

  • Barometric Pressure Sensor
  • Accelorometer/Gyroscope
  • Magnetometer
  • Ultrasonic Sensor (backup is LiDar in case of noise interference)

  • Magnetometer not needed for takeoff stage
  • GPS not needed for takeoff stage
  • Temperature Sensor not required

Barometric Pressure Sensor

Communication Type:
Model :

Accelorometer

Communication Type:
Model:

Ultrasonic Sensor / LIDAR Sensor

Communication Type:
Model:

Peripherals

Technically none of these are NECESSARY although they add extra support for debugging (and they look/sound cool)

  • OLED Screen
  • Heartbeat LED built-in
  • Status LED
  • Buzzer

OLED Screen

Communication Type: I2C
Model:

Motion

  • Brushless motor x4
  • Servo x2
  • ESC x4

  • Servo x2 not needed for takeoff stage

Brushless Motor

Control Type: PWM
Model: DJI

Servo

Control Type: PWM
Model:

Power

  • 2s LIPO
    • PCB Power
  • 6s LIPO
    • Motors / Servos Power

Early PCB Designs

Pasted image 20230915120737.png Pasted image 20230915120807.png

Old

List

Chips

  • STM32F4
  • ATMEGA164PU

Sensors

  • Barometric Pressure
  • Accelorometer
  • Ultrasonic Distance
  • GPS
  • Temperature: x1-5
    • Theses will use I2C ADC chips (1 can take in 3 analog signals)
    • PCB
    • Motor 1-4

Communication

  • ESP Wifi Module

Error Code / Status

  • OLED display
  • Buzzer
  • LED x10 (STM:4, ATMEGA:5, Passive:1)
    • STM32 Master Status: x3 (Connected to STM32)
      • green
      • yellow
      • red
    • ATMEGA Master Status: x3 (Connected to ATMEGA)
    • PCB power status (Connected to power)
    • WiFi Com Status (Connected to ATMEGA)
    • STM > ATMEGA Com Status x2 (Connected to ATMEGA & STM32)

Data Logging

  • Micro SD r/w

Movement

  • DJI Inspire 1 motor: x4
  • Servo: x4
    • TVC vertical
    • TCV horizontal
    • Left aileron
    • Right aileron
  • ESC: x4

Power

  • 2s LIPO
    • PCB Power
  • 6s LIPO
    • Motor Power

MAP

flowchart LR
subgraph STM32F4
	usart1[USART]
	usart5[USART]
	i2c1[I2C]
	gpio1[GPIO]
	gpio2[GPIO]
	gpio3[GPIO]
	gpio4[GPIO]
	gpio5[GPIO]
	gpio11[GPIO]
end
subgraph ATMEGA164PU
	usart2[USART]
	usart4[USART]
	i2c2[I2C]
	gpio6[GPIO]
	gpio7[GPIO]
	gpio8[GPIO]
	gpio9[GPIO]
	gpio10[GPIO]
end
subgraph ESPWIFI
	usart3[USART]
	wifi1[Wireless Interface]
end
subgraph sensors
	adc1[ADC to I2C]
	adc2[ADC to I2C]
	temp1[Temperature Sensor]
	temp2[Temperature Sensor]
	temp3[Temperature Sensor]
	temp4[Temperature Sensor]
	temp5[Temperature Sensor]
	bar1[Barometric Pressure Sensor]
	acc1[Accelorometer]
	us1[UltraSonic Distance Sensor]
	gps1[GPS]

	temp1 --ANALOG--> adc1
	temp2 --ANALOG--> adc1
	temp3 --ANALOG--> adc1
	temp4 --ANALOG--> adc2
	temp5 --ANALOG--> adc2
end
subgraph status_indicators
	led1[STM32 GREEN]
	led2[STM32 YELLOW]
	led3[STM32 RED]
	led4[ATMEGA GREEN]
	led5[ATMEGA YELLOW]
	led6[ATMEGA RED]
	led7[PCB Power]
	led8[WiFi Communication]
	led9[USART to ATMEGA]
	led10[USART to STM32]
	buz1[BUZZER]
	oled1[OLED Display]
end
subgraph movement
	m1[MOTOR]
	m2[MOTOR]
	m3[MOTOR]
	m4[MOTOR]
	srv1[TVC Vertical Servo]
end
usart1 --USART--> usart2
usart4 --USART--> usart3

i2c1 --I2C--> bar1
i2c1 --I2C--> acc1
i2c1 --I2C--> adc1
i2c1 --I2C--> adc2
usart5 --USART--> gps1
gpio1 --> us1

gpio2 --> led1
gpio3 --> led2
gpio4 --> led3
gpio5 --> led9
gpio6 --> led4
gpio7 --> led5
gpio8 --> led6
gpio9 --> led8
gpio10 --> led10
gpio11 --> buz1
i2c2