Feb-25, 2020 - Got printed circuit boards for transmitter (and li-ion battery charger) from jlcpcb today. Soldered it up and got it running - picture in gallery.
It has been a couple months since I have done much direct work on this project but am starting to get back into it a little now. In that time I have been looking into some background projects to help support me in this project. In addition to spending a few day familiarizing myself (and writing libraries) for the NRF24L01+LNA with antenna, I have made project posts on this site on several topics related to this project -
- BMP280 Data Collection With ESP
- A Li-Ion battery (1S - 6S) charger and tester
- Drone Kit Development - Thrust Measurements
- Magnetometer Demonstration
As result of this aside I have decided to try to have my main thrust loop closing in on bmp280 altitude measurements, to build my own battery charger and to try to avoid using a magnetometer. The range of the esp's espnow radio is somewhat of a limitation so I have included an option to use a nrf24l01+ on both the flight controller and the transmitter.
Given that I was closing in on a version of this project that I wanted to build and the breadboard was getting a little crowded (especially after adding the bmp280, the nrf24l01+ and a gps receiver to the flight controller board), I looked into building a printed circuit board. I haven't built a pcb for a home project (well since the old FeCl days as a kid) before, I have done it at work (where I didn't even have the cad tools on my computer) and had techs or vendors do the supervised capture, layout and ordering (did a couple 2 layer test jigs a few times but as I recall those were still in the $200+ range and the software was not very good). This time I tried EasyEDA and was surprised at how easy, fast and cheap pcb design is these days, I had the pcb for the li-ion battery charger done the same day - 5 2-layer 100x100mm boards are $2 with $6.33 3 week shipping - wow! You can install the router easily on windows or linux systems and it will route the board in about a second - very intuitive interface with a schematic capture comparable to industry leaders, extensive component libraries (beware some contributed by individuals and not verified), hurry and download and maybe you can be the one millionth easyeda user!
I have submitted orders for both the flight controller board and the transmitter PCB boards for this project - the boards have completed manufacture and been shipped. Pictures of the boards are included in the gallery.
What is demonstrated working so far as test and co-functional software libraries -
- ESP32 module with C program written using only software cloned from https://github.com/espressif/esp-idf
- SPI DMA interface to MPU9250 reading gyro data at 8K samples/sec, accelerometer data at 1K samples/sec (spiclk = 5MHz)
- Low pass filter on accelerometer data, and xyz to spherical trig conversion to calculate accelerometer based pitch and roll at 100Hertz (will try to go higher)
- Complementary filter fusion - preserving high speed component of gyroscope data and and low speed component of accelerometer data
- PID control inner control loop (attitude measurement) integrals at 8K update rate, external PID (attitude control) updates at 100+Hz
- PWM generated servo outputs from outer control loop PIDs to four ESCs updated at 480Hz
- MPU9250, BMP280 and ESC calibration functions
- BMP280 pressure data used in altitude control PID
Receiver/Transmitter Radio Set (one for esp8266 transmitter and one for esp32 flight controller)
- Have had receiver working in both TCP/IP and ESPNOW modes, recently added NRF24L01 on flight controller and transmitter
- In TCP/IP mode have hosted remote webpage with a couple virtual joysticks, unfortunately limited to ~5 packets/sec, maybe useful for some applications
- In ESPNOW mode can transact more than 100 packets per second with much higher download bandwidth for blackbox data, limited to about ~100 feet.
- A pair of NRF24L01+/LNA has better range than the ESP radio (probably mostly due to the antennas on both sides), has lower overhead (tcp transmit on esp uses lots of resources) and can handle 100 bidirectional packets per second (and no power rail glitching from esp transmits).
- ESP8266 D1-mini module
- I2C bus reading ADS1015 analog to digital converter hooked up to two joysticks
- ESPNOW link to flight controller/receiver hard coded with MAC addresses, comes on quickly, can reestablish and no startup order
- NRF24L01+ option working and under consideration.
- OLED Display (height, time remaining, x y displacement)
- Magnetometer added for possible future 'heads up'? operation (drone orients to position facing of transmitter)
What is demonstrated working so far in hardware -
The F-450 is built and wired. Did a few test flights of limited success, eventually discovered one of the esc/motors was bad and ordered a replacement, that pretty much when I started working on other stuff about two months ago.
Various versions of transmitter built and talking to flight controllers, one unit with very nice set of joysticks. Plenty of battery packs for transmitter.
Have two 3S batteries in good working order and good mounting arrangement on drone.
The logs contain a history of sorts of how this project has meandered.
February 21, 2020 - While waiting for PCBs decided to take all my attitude measurement components and get them working on a simple breadboard to help get acquainted with what to expect while walking around and monitoring results. The breadboard has five modules on it -
mpu6500 - 5MHz spi lookup to esp (dma), reading three gyroscope and three accelerometer axes at 1,000 readings per second,
qmc5883l - three axes magnetometer measurements hooked up to the i2c bus at about 10 samples/sec,
bmp280 - atmospheric pressure measurements, i2c about 10 measurements per second,
OLED display - hooked up to i2c updating at about 2x per second.
These are served by ESP32 module running custom modules in esp-idf environment. The esp provides calibration for these modules and keeps track of the current measured state. The gyro and accel measurements are 'fusion'ed by a complimentary filter to provide a highly responsive and real-time pitch and roll attitude calculation. The magnetometer provides heading information for yaw adjustments and the barometric pressure provides altitude measurements that will be used to calculate throttle settings. Each of the four throttle, yaw, pitch and roll numbers will be added or subtracted into each of the four servo commands to motor ESCs. A picture of my breadboard has been added to gallery.