DRONE SWARM vErsion 3 programming (Low LEvel):

1. Flashing Firmware

From the factory, the memory of the microcontrollers is completely empty. This means that the code for programming the microcontroller using the USB port is not there. This had to be flashed using an in-system programmer (ISP) before any development work. The green breakout board in version 3 was designed for exactly this purpose. It exposed the ISP pins on large, easy to reach headers without making the control board larger and heavier.

2. Low Level Controller:

As mentioned before, the low level controller’s job is to either hover the drone in midair or move in a certain direction at a certain speed. This is accomplished through a PID controller monitoring the acceleration and orientation data and correcting for disturbances in level flight by adjusting the speed of the motors.

The relatively simple task means that the processor can execute the control loop for steady flight nearly 100 times per second in order to respond to changes as quickly as possible. This is also the maximum refresh rate of the IMU sensor.

3. Getting Each Component of the Low lEvel System to Work

Connecting to the Low Level Controller via In-System Programmer

3.1 Testing Motors:

The major problem with version 2 of this project was that the control signals for the motors were 3.3v instead of 5v, meaning that the control board could not communicate with the motor driver board. To verify that this problem was resolved and all motors were working, I wrote a small test program to run all of the motors in sequence.

This proved that everything was connected properly and the motors were all wired in the correct direction.

Coordinate-frames-D-S-and-W-drone-frame-D-is-attached-to-the-drones-body.png

3.2 Getting Absolute Acceleration data:

The low level controller takes its positional data from the Accelerometer in the IMU. These vectors are {D} in the diagram, which are rotated with respect to the drone’s orientation in space.

The high level controller uses the GPS, which gives it data as to its position on earth. This is {W} in the diagram, which does not change as the drone rotates in space.

The ultimate goal of the low level controller is to be able to execute a simple command of a direction in which to fly and a speed to fly at. In order for these commands to be executed properly, the low level controller needs to re orient its acceleration data relative to the world coordinates. I.E. it needs to rotate {D} such that it aligns with {W} thus obtaining {S}.

This was done using linear algebra to obtain a rotation matrix from the gyroscope and magnetometer in the IMU. This matrix was used to rotate the accelerometer data and also to subtract the acceleration vector for gravity, which is always 9.81m/s^2 pointing straight down.

Here is a video demonstration of the absolute acceleration data visualized on my laptop. You can see that the data only changes based on how the drone is moved, regardless of how it is rotated.

Now the low level controller knows its orientation and acceleration, and can control the motors. The algorithm that handles all of this data and determines the speed of the motors is discussed in the next work log.