dRehmFlight VTOL - Teensy (Arduino) Flight Controller and Stabilization

NickRehm

Member
Hi all,

I'm sharing my custom flight controller code written for the Teensy 4.0 and MPU6050 IMU. The best summary I've been able to prepare thus far:

"dRehmFlight VTOL is a bare-bones flight controller for hobbyists or researchers wanting to get something flying fast with the ability to quickly and intuitively adapt to unique configurations. The Arduino environment makes it easy to make your additions--from basic functionality to sensor integration to custom inner-loop control--without the hassle of dealing with spaghetti code cluttered by features you'll never use."


Download: https://github.com/nickrehm/dRehmFlight

Features:
  • Code modifications and compiling done within the Arduino IDE with Teensyduino add-on.
  • Default code supports 6 ESC outputs using OneShot125 Protocol, and 7 conventional PWM outputs for ESCs or servos, with the ability to modify the code for extra outputs for custom setups.
  • Support for conventional PWM, PPM, or SBUS receivers.
  • MPU6050 and MPY9250 IMUs supported.
  • Easy to use control mixer with stabilized axis variables and ability to pass direct, unstabilized commands to the motors or servos direct from the transmitter.
  • Three PID controller types including rate and angle-based setpoint.
  • Simple variable fading, with support for more advanced options planned in the future.
  • Default hardware setup (Teensy 4.0 and MPU6050 IMU) costs less than $30 and weighs less than 15 grams.
  • Comprehensive documentation with explanation of every function and variable, as well as tutorials for setting up the hardware and modifying the code for your application.

This is not just meant to stabilize multirotors (though it does that really well). Here is an example of what you can do with the stock code after adding ~20 additional lines of code in the provided control mixer:


So, if you know a little bit about Arduino, this project may be for you to get practically any vehicle type stabilized in the air. If you don't know about Arduino--don't worry. Check out the provided documentation (GitHub download) which includes a complete overview of the code as well as detailed tutorials for setting up the hardware and modifying the code for your application. I'm also releasing a video series covering everything (+more) in the documentation:




Code Walkthrough Video: https://www.youtube.com/watch?v=_n5GBudUf5Q&feature=youtu.be

Hope some of you tinkerers find this project useful,

Nick
 
Last edited:

mcmarker

New member
Thank you! I have been looking into VTOL FC stuff a lot recently and this a super interesting addition to the list! I appreciate your work and sharing
 

NickRehm

Member
Thank you! I have been looking into VTOL FC stuff a lot recently and this a super interesting addition to the list! I appreciate your work and sharing
Very happy to share, it's something I always wanted but couldn't seem to find in other FC options out there. Hope you can get something flying soon!
 

kpixels

Antigravity or bust...
Nice work! All those pins make me feel like I'm going back in time. Found the controller and IMU on Amazon for less than $30. Can't wait to play with it this winter when I have some extra time. Wonder if this could also be used to improve camera gimbals. Thanks!
 

NickRehm

Member
Nice work! All those pins make me feel like I'm going back in time. Found the controller and IMU on Amazon for less than $30. Can't wait to play with it this winter when I have some extra time. Wonder if this could also be used to improve camera gimbals. Thanks!

The best thing about the Teensy is you can break it out however you need, like any other arduino project. I have one that I've broken out with all the pins, and another that I plug/unplug around different protoboards that have been broken out for the specific platform
 

LitterBug

Techno Nut
Moderator
The software would be the krux for the challenge.... being able to have it hover no matter what the orientation. Motors in 3D mode, Could hide 18650 batteries in the frame... just a few ideas... Would be cool to do this BIG with 9-12" props.
 

LitterBug

Techno Nut
Moderator
The best thing about the Teensy is you can break it out however you need, like any other arduino project. I have one that I've broken out with all the pins, and another that I plug/unplug around different protoboards that have been broken out for the specific platform
I just picked up a Teensy 4.1. HOLY SHMOKES there are a TON of PWMs, and 600mhz stock clocking.
1605203624824.png
 
Last edited:

JasonK

Participation Award Recipient
Motors in 3D mode
I don't think 3D mode will work, because there are orientations where a motor might need to switch thrust directions rapidly. Would probably need to be a variable pitch system like a 3D heli for each of the props.
 

LitterBug

Techno Nut
Moderator
I don't think 3D mode will work, because there are orientations where a motor might need to switch thrust directions rapidly. Would probably need to be a variable pitch system like a 3D heli for each of the props.
You must not have worked with a 3D setup that worked well....

Actually, the more I think about this.... If I was flying in acro FPV, I could set up a mix pretty easy...... I may just have to build/print a proof of concept.
 

JasonK

Participation Award Recipient
You must not have worked with a 3D setup that worked well....

Actually, the more I think about this.... If I was flying in acro FPV, I could set up a mix pretty easy...... I may just have to build/print a proof of concept.
I haven't flown any "3D" quads, but the few videos I have seen on RR, they noticed the time it took for the props to switch directions, so I would take it as at least 1/4 second, but I could see situations were it would need to toggle much faster then that.

Are you saying there are "3D" quad setups that can switch thrust directions 20+ times a second or more (IE sub 0.05 seconds)?

you might also want to look at some of the requirements:
  • The Lynchpin Drone must be able to rotate into any orientation while maintaining position.
  • The Lynchpin Drone must be able to move in any direction regardless of its orientation.
  • The pilot must have control of orientation and position.
  • Control of orientation and position must be independent (for example, the control "ascend" will always move the drone upwards relative to gravity, even if the drone is "upside down").
This will take full 6 axis control, the quad's PID systems are going to need to use quaterions instead of eular angles (I have seen notes that seemed to imply at least some firmwares are still using eular angles) to prevent gimbal lock.
 
Last edited:

LitterBug

Techno Nut
Moderator
Direction change time depends on quite a few things. Rotating mass, motor strength, how fast the props are spinning before initiating a change in direction, and the type of maneuvers you are doing to name a few. Sure, you could do variable pitch, but that adds a lot of weight and complexity. In the end, there is always more than one way to do things. Heck, run twelve motors in pairs that oppose each other.
 

NickRehm

Member
Thanks for putting that contest on my radar...had a look through the website, and all I have to say is: I have doubts there will be payout. Looks like a scam to me.

With that said, a vehicle like this is entirely possible and has been done before:


Not sure what the hippy-dippy fascination with the required geometry is...
dRehmFlight can do this, but would require a slightly different controller function to get it working 100%. Attitude estimate is already using quaternions, so absolute orientation is known, but that is decomposed into euler angles for the linear PID controllers that are already implemented. I guess the idea of the competition is that the vehicle would hover around, always knowing what 'down' is, so you couldn't cheat it and use a mixed rate controller. You could get fancy with transformation mixing on a rate-based controller, but you won't know where down is after a few seconds when the gyro error accumulates with integration.
"The Lynchpin Drone may be flown in full acro mode" as it states on the website is literally impossible.

The proper way to approach this problem (and the way its already been done) is to develop a dynamic model of the motor layout (constrained by the given geometry) and design a proper 6DOF nonlinear controller. No thanks.
The biggest challenge is designing an actual controller (i.e. radio) that can do what he's asking for. 3 degrees of freedom for rotation, and 3 for translation mean we would need another stick, better yet a completely unique layout. Some thing like a gimballed CAD mouse for each hand
1605219449980.png


Overall, I'm unimpressed by the competition. Very vague, no guarantee of payout, and its asking to solve a problem that's already been solved. Something like this would serve no purpose either other than being kinda cool to look at. Piloting it manually would be completely unintuitive and useless.
 

JasonK

Participation Award Recipient
as far as the controller goes, my friend (when I was in HS) had a 6 axis controller that was a ball and you twisted/pushed the ball (it has 6 DoF) to actuate the axis. It was great for descent with the game having full 6 axis movement. I can't find a picture of it...


edit... found it:
1605221056379.png
 

Attachments

  • 1605220628959.png
    1605220628959.png
    18.7 KB · Views: 0
Last edited:

JasonK

Participation Award Recipient
Thanks for putting that contest on my radar...had a look through the website, and all I have to say is: I have doubts there will be payout. Looks like a scam to me.

With that said, a vehicle like this is entirely possible and has been done before:
mildly different, but yes, I agree that the issue is generally solved

Not sure what the hippy-dippy fascination with the required geometry is...
see quite a few comments in places about this questioning the general sanity of the person creating the challenge.

Overall, I'm unimpressed by the competition. Very vague, no guarantee of payout, and its asking to solve a problem that's already been solved. Something like this would serve no purpose either other than being kinda cool to look at. Piloting it manually would be completely unintuitive and useless.
the Terms also require you to give over 100% of the IP related to what you created just for submitting (not even if you win) - per comments from people who took the time to read it.. on the above video. I agree it is a mess, and not enough payout for the work to make it happen.
 

LitterBug

Techno Nut
Moderator
Haven't tested my 4.1 yet, but pin mapping looks identical to the 4.0 so all my code should work fine right away. The possibilities with that io are endless
Yeah, more onboard flash, SD built in, more solder through pins and pads on the bottom for PSRAM or flash. I added 2x8GB ram. Can use SD for flash.
 

NickRehm

Member
Completely forgot about onboard SD... and here I am using an openlog with the 4.0 for data logging when I have the 4.1 buried in my electronics drawer haha
 

LitterBug

Techno Nut
Moderator
Completely forgot about onboard SD... and here I am using an openlog with the 4.0 for data logging when I have the 4.1 buried in my electronics drawer haha
You can get one of those surface mount half SD sockets to solder on the bottom of an 4.0 too.
https://www.digikey.com/en/products/detail/molex/0475710001/3262277

The Current TinyDuino beta SDFAT SD/SDIO libraries are only running HS 25MB/s mode and not UHS-1. The T4.x boards technically should be capable of supporting full UHS-1 @ 104MB/s. I found a modest speed bump, especially on writes, formatting SD cards with EXFat with the Beta Libraries. My Best card gets rougly 21MB/s Write, and 23MB/s read. Probably quite a bit faster than you could get with the OpenLog. i have a couple of the OpenLager boards that can do 2Mb/s serial, and even that seems slow these days. LOL

LB
 

LitterBug

Techno Nut
Moderator
as far as the controller goes, my friend (when I was in HS) had a 6 axis controller that was a ball and you twisted/pushed the ball (it has 6 DoF) to actuate the axis. It was great for descent with the game having full 6 axis movement. I can't find a picture of it...


edit... found it:
View attachment 183156

Not sure if any of you are old enough to remember Descent (which JasonK mentioned) from the mid to late '90s, but it was a 6 DoF Hovercraft FPV view shooter. I had a friend who had one of those ORBs. I only had a 3axis joystick with a few buttons and keboard for the rest. He got really good with that orb and it was really tough to compete. 3 Axis with a 2 axis hat helped, but without the precision of the orb for sliding.