Building an autopilot from scratch using a RaspBerryPi Zero : Mini Zee

I finally received my Raspberry Pi Zero, just in time to get into the DIY challenge of building a smart drone with the Pi Zero and APM under 100$. I called this project: MINI-Zee

How this can be done?
Well first of all, thanks to Victor and the team at Erle Robotics for releasing the plans and software of their PXFmini. This is a real inspiration for building my own board, because all the parts are available at a cheap price and are relatively easy to assemble and interconnect using through-hole breadboard, providing you are very experienced with this type of build. Thanks to Mirko as well, for having introduced a real DIY autopilot project that allows us to experiment with a fully working and well supported BeagleBone based ArduPilot Cape called the BBBMINI.

Bill of Material (US$ - Transport & taxes excl.):
Raspberry Pi Zero 5.
MPU 9250 (SPI 9 dof IMU) 8.
MS 5611 (SPI Baro) 9.
PCA 9685 (16 channel PWM Servo Driver) 5.
3.3 v. regulator 1.
BEC 3 amps 3.
Breadboard, Resistors, Connectors, Misc. 7.
AutoPilot: 38.
HobbyKing Spec FPV250 V2 Quad Copter
ARF Combo Kit - Mini Sized FPV 60.
Total: 98.
*This is Banggood price; I had an ADAFRUIT –PWM on hand, and I really recommend going with ADAFRUIT, because of all the effort they put on making a great tutorial and drivers for this product. Note: Just like Erle , the USB WIFI, GPS and the Radio Control are excluded.
Building:

A) Hardest part: Get a RASPBERRY PI ZERO (Where is my Zero site)
B) Hardware - See BOM
C) Board Schematics : Erle pxfmini
D) Board Software: Erle pxfmini
E) LOAD LATEST Raspbian-Jessie
Disable serial Login (Allow GPS on serial Port)
Enable , I2C, SPI , Serial
Disable Console = Auto Log on a shell

F) LOAD RT-PREEMPT
http://www.frank-durr.de/?p=203
Load Test Result: TEST: T: 0 ( 1136) P:80 I:500 C: 100000 Min: 16 Act: 31 Avg: 32 Max: 157

G) MAKE ArduCopter
Special MINI-ZEE release:

  1. The MPU 9250 is mounted on the Z-Axis, so we need to change :
    CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXFMINI
    , _default_rotation(ROTATION_YAW_270) = to ROTATION_NONE
  2. The PCA9585 has no external clock, and the ESC are connected to ports 1-2-3-4, so we need to change:
    static RCOutput_PCA9685 rcoutDriver(PCA9685_PRIMARY_ADDRESS, true, 3, RPI_GPIO_27); -to-
    static RCOutput_PCA9685 rcoutDriver(PCA9685_PRIMARY_ADDRESS, false, 0, RPI_GPIO_27);
    H) Fly the MINI-ZEE == Add these to /etc/rc.local

echo “Starting ArduCopter” >> /home/pi/bootlog
sudo /home/pi/ardupilot/ArduCopter/ArduCopter.elf -A udp:192.168.gcu-address:14550 -B /dev/ttyAMA0 > /home/pi/startup_log &
exit 0
I) FIRST FLY LOG:

Thanks to the damping platform, the vibration level is within specs. Video is available for anyone interested…:wink:

Conclusion:
This project took about 20 hours to complete. As you can see, I really enjoyed doing some hardcore DIY to demonstrate that it is still possible to build your own flight controller from a Linux Based system. I do not recommend to try this as a first project, but if you are interested, get a BBBMINI, this is the best introduction to DIY and if you want to fly a Raspberry Pi Zero, it is much easier to buy a PXFMINI.

2 Likes

Here is an update:
Upgraded to latest Raspberry Pi Zero and connecting camera
Had to reduce EMI for the GPS (7 series) using MuMetal shield == Racer Look :slight_smile:
Changed the Wifi Dongle for a 5 Ghz + Hostapd so it is working as an Access Point
Changed Motors for more powerful 2206 size.

1 Like

Here is another update on conflicting 2,4 Ghz between WIFI and Radio-Control.
,I switched WIFI to an EDIMAX AC600 running as an Access Point on 5 GHZ with the use of HostApd and loading this DRIVER.
Here is a picture of the modified USB Dongle with the micro USB adapter cable soldered directly + a 5volts BEC + a RP-SMA adapter cable to attach the 5GHZ antenna.
So far the tests are good, I’ts flying smoothly and the video is fluid at 640x480 x 20fps up to 500 Meter.

1 Like

Here is a picture of my routing; Imu on top , Baro bottom, they share the same SPI bus, with different CS (Chip Select), VCC, Ground and X=Not Connected.
Hope it can help :wink:

3 Likes

First of all congratulations for the project, very inspiring, it’s the first one I meet.

I’m starting in the area of drone projects, and I have an idea of making an autopilot for mine, I found your topic interesting and would like to exchange some ideas with you, for example, does the drone follow a preconfigured route? Can he have a reasonable speed?

I am grateful now.

Thank You.

The speed is related to the type of quadcopter, In the model showned here , the speed can be quite good (up to 100 Kmh) in manual (stabilized or acro mode).

I suggest you go through the wiki , you will find answer to most of your questions: http://ardupilot.org/copter/docs/auto-mode.html

And for building, you might consider building a BBBMINI https://github.com/mirkix/BBBMINI this is easier to build and you benefit from a better support.

Ok, I’m very grateful, it will be of great help, and I already read about BBBMINI, it really supplies all expectations.

Once again, congratulations on the project!

Could you tell me where you bought the drone structure? I live in Brazil, there are no stores with this material.

@Joao_D_Junior ,
most of my stuff is from China, either Banggood , Aliexpress or HobbyKing

@ppoirier , and others…

Hi!
I got inspired by this post a long time ago, and finally I started to build my own version of your project. I understand that the Pi0 isn’t the best option for running Ardupilot, I’m using the Pi0 because to learn both Raspberry and the Ardupilot code.

I’m running Raspian Stretch with kernel 4.14.81-rt47+ (RT patch from the official raspian kernel git) and Arducopter 3.6.3 compiled for PXFMINI with the mods for PCA9685 as you have described. I see that the code has changed a bit since you made your controller.

I have got everything working except the PCA9685. Without the PCA9685 I can start arducopter on the PI, and connect to my GCS. When I connect the PCA9685 it’s not possible to establish an connection with the GCS. It looks like arducopter starts without any errors.

Is the problem the change in the code regarding how ardupilot handles the PCA9685 over i2c?

Best regards
Alex

@JAR4x4 cool, as noted here:

Have you modified these lines ?

@ppoirier , thanks for your quick reply!

Yes, I have modified that line, just changing true to false, and 3 to 0

running sudo i2cdetect -y 1 shows the address of the PCA9685. I have also tried to run raspbian without the RT patch = same problem

Did you connect the PWM enable (GPIO27) pin 13 to the PCA OE ?

Yes, I have tried both with and without PWM enable connected

I’m going to check now if the PCA is actually working with the Adafruit python library

Yep, I was about to suggest that and checking with a bus analyser if you have one. Otherwise the code might be broken, I dont think anyone is building pxfmini these days… It’s a ChiBios world with F4 & F7 FC now…

Hehe, I know… But I want Linux onboard for the learning… :wink: I don’t have a bus analyzer, but i wil hook my scope up to PWM0 and see what happens when i run the python example. I will post back with my results.

I think Erle still is selling the Pxfmini? Maybe they run a custom erle ardupilot flavour?

I think Erle is running an oudated version of ardupilot, … looking at Erle Forum I dont see much activity either…
Anyway, this is still a good primer project for anyone interested in linux integration , as long as the code is not broken :slight_smile: and be aware that the PPM routine using the DMA Soft Int has not aged well, it had a tendency to crash on since 3.5

Ok, I have seen that, but I will try to compile the erle fork now, and see if that helps.

I hooked my PCA to my scope and ran the Adafruit test code, looks like the PCA works =)

Yes, I have seen that there has been some issues regarding PPM. No problem for me in this project, I’m going to use mavlink for controls over a wifibroadcast setup I’m also working on =)

Might try adding a bus define ? … something like:
#define HAL_RCOUT_RCOutput_PCA9685_I2C_BUS 1
here: