dRehmFlight VTOL - Teensy (Arduino) Flight Controller and Stabilization

JasonK

Participation Award Recipient
float are a type of numerical variable in the computer world, they are stored in a type of scientific notation, and therefore can have decimal points to them. (integers are the other primary type, and they can only represent whole numbers).

In the code, the math appears to be done with floats, then turned into an output signal at the very end of the logic.
 

the rc project

Well-known member
float are a type of numerical variable in the computer world, they are stored in a type of scientific notation, and therefore can have decimal points to them. (integers are the other primary type, and they can only represent whole numbers).

In the code, the math appears to be done with floats, then turned into an output signal at the very end of the logic.
I DID IT!! I’ve figured out the if statement for transitions. I was running into an “error compiling”, the. Realized that the error code at the bottom tells me what’s wrong.... still learning guys. My problem was not removing the slashes and pound keys. Guess it’s just noob things.
 
Last edited:

tamuct01

Well-known member
Thanks for this project! I'm looking to build a V-22 Osprey and started by using a FrSky S8R receiver for stabilization and passing that through an Arduino with custom mixing code. The results were less than spectacular. I'm trying to wrap my head around ArduPilot, but I think I'd have to reinvent the wheel to make such a craft work in their ecosystem. I'll take a look at this project and see if it will work for me!
 

JasonK

Participation Award Recipient
Thanks for this project! I'm looking to build a V-22 Osprey and started by using a FrSky S8R receiver for stabilization and passing that through an Arduino with custom mixing code. The results were less than spectacular. I'm trying to wrap my head around ArduPilot, but I think I'd have to reinvent the wheel to make such a craft work in their ecosystem. I'll take a look at this project and see if it will work for me!
i was looking at ArduPilot and I believe that it has bi-copter tilt roter as an option already in the system. I just had issues with the configurator that worked on Linux to get it to let me setup the FC that I had.
 

NickRehm

Member
Hey rcjetflyer, i've been learning a lot because of the teensy! right now i've got the wing of a Do31 that can hover!!!!!! still have lots of work to do till i can call it a plane but still a huge success. however i am a little stumped with how to set up the transition. In section 9.9 on the PDF it says "if(channel_6_pwm > 1500 { // hover mode". When i go directly below the controlMixer() (still in the control mixer section) the code says
"
//Example use of the linear fader for float type variables. Linearly interpolate between minimum and maximum values for Kp_pitch_rate variable based on state of channel 6:
/*
if (channel_6_pwm > 1500){ //go to max specified value in 5.5 seconds
Kp_pitch_rate = floatFaderLinear(Kp_pitch_rate, 0.1, 0.3, 5.5, 1, 2000); //parameter, minimum value, maximum value, fadeTime (seconds), state (0 min or 1 max), loop frequency
}
if (channel_6_pwm < 1500) { //go to min specified value in 2.5 seconds
Kp_pitch_rate = floatFaderLinear(Kp_pitch_rate, 0.1, 0.3, 2.5, 0, 2000); //parameter, minimum value, maximum value, fadeTime, state (0 min or 1 max), loop frequency
}
*/

my question is, am I in the wrong place or do i edit this part of the code?
(edit: i have another question... I don't quite understand floats. are they just servo trim?
once again sorry for the noob questions but here's some details of the project if it helps. I am using 4x2206 quad motors for hovering, and 2 larger motors as pushers along with rudder, aileron, and elevator. im building a Do31 like i said i was dreaming about! only this one will be powered by only props rather than edfs for a multitude of reasons. it is essentially a twin pusher with a quad copter in the wingtips.

Yea that section you found was just commented out as an example of using the channel_6_pwm variable to toggle flight modes, as well as using the function that'll fade a variable. Glad you got it figured out and excited to see your first flights
 

NickRehm

Member
I'll take a look at this project and see if it will work for me!

It will ;)

i was looking at ArduPilot and I believe that it has bi-copter tilt roter as an option already in the system. I just had issues with the configurator that worked on Linux to get it to let me setup the FC that I had.

I could never wrap my head around getting ardupilot setup...too much fluff/specifics/options that got in the way of just getting a simple PID controller in the air
 

tamuct01

Well-known member
i was looking at ArduPilot and I believe that it has bi-copter tilt roter as an option already in the system. I just had issues with the configurator that worked on Linux to get it to let me setup the FC that I had.

Yes, ArduPilot does have that, but I'm building a scale-ish version of the Osprey with a pair of 450-sized helicopters that have collective and cyclic pitch servos on each rotor. Ardupilot has no concept of this yet. It looks like we would have to combine bits of trad-heli with the quadplane code to make it work, and I don't have that level of understanding of the project. I'm looking for something simpler with common angle, horizon, and acro modes and that's about it. I don't need all the mission planning, GPS, etc. for my project.
 

the rc project

Well-known member
Hey @Rcjetflyer2, I am still working on the cl84 project but I couldn’t help myself because I have the extra parts for another teensy. So I’m playing with 2 flite test 1806 motors (and the 20a flite test esc) I’m going to try a v22.(mostly interested in hovering around) But regarding the escs, for power to the teensy and the servos do I just run the ground and positive from one of the escs to the 5v? The escs are bl_helis(i think) does this mean the signal goes to the oneshot125 pins? If they are not bl_helis, use the pwm?
Cheers mate
 

NickRehm

Member
If you've got the servo power rail all wired up like in my default setup, then yes--you can plug the esc straight into the 3-pins and it should power the teensy as long as you've bridged the power rail to the 5v input on the teensy. If they're blheli then they should run out of the box with the oneshot protocol or pwm, your choice.

One note since you're using the ESC's onboard BEC for 5v power: I wouldn't run more than 3 servos, any more and the voltage on the low amp BECs tends to slightly dip and reset the teensy. Teensy likes very clean 5v input, so I typically run a dedicated BEC on larger projects with more servos
 

Matthewdupreez

Legendary member
If you've got the servo power rail all wired up like in my default setup, then yes--you can plug the esc straight into the 3-pins and it should power the teensy as long as you've bridged the power rail to the 5v input on the teensy. If they're blheli then they should run out of the box with the oneshot protocol or pwm, your choice.

One note since you're using the ESC's onboard BEC for 5v power: I wouldn't run more than 3 servos, any more and the voltage on the low amp BECs tends to slightly dip and reset the teensy. Teensy likes very clean 5v input, so I typically run a dedicated BEC on larger projects with more servos
have you considered a arduino stabiliser that can be used for fixed wings?
 

tamuct01

Well-known member
On my V-22 project, I'm actually using 2 BECs: One small 5V to run the Teensy and another set at 6V to run the servos. The digital servos are a bit power hungry and like to run at a higher voltage.
 

NickRehm

Member
have you considered a arduino stabiliser that can be used for fixed wings?

This project works on fixed wing as well and is arduino-based. Some people have actually ported it over to arduino boards like the nano, though those are much slower so its not as ideal for hovering
 

Matthewdupreez

Legendary member
This project works on fixed wing as well and is arduino-based. Some people have actually ported it over to arduino boards like the nano, though those are much slower so its not as ideal for hovering
luckily as a novice pilot you probably aren't going to hover you cub;)
 

NickRehm

Member
i am no expert so i am wondering whether anyone could make the necessary mods for me?
i do understand simple codes but this is a little deep at the moment for me

Check out this video starting at 11:11, then skip a little ahead to 17:11


After you setup your radio to talk to the teensy properly (tutorial and video in the docs), all you need to do is change 2-3 lines of code in the control mixer, basically telling the servo and motor channels how they should move. For example, an elevator on an airplane should respond to the pitch axis--either stabilized command from the pid controller or direct from the transmitter. There are some variables that you use to assign this functionality to the respective servo pin, whether you want stabilized or unstabilized control is up to you.
 

Matthewdupreez

Legendary member
Check out this video starting at 11:11, then skip a little ahead to 17:11


After you setup your radio to talk to the teensy properly (tutorial and video in the docs), all you need to do is change 2-3 lines of code in the control mixer, basically telling the servo and motor channels how they should move. For example, an elevator on an airplane should respond to the pitch axis--either stabilized command from the pid controller or direct from the transmitter. There are some variables that you use to assign this functionality to the respective servo pin, whether you want stabilized or unstabilized control is up to you.
awesome thanks a ton
 

tamuct01

Well-known member
where or who can i get the code for a fixed wing?

For fixed-wing, you'll basically strip out/comment the "motors" code and use regular servo PWMs for your outputs. Nick has done a great job documenting all of this, but the provided demo code is focused on multi-rotors. Take a look at his videos and documentation, and if you have any issues you can PM me for help.
 

Matthewdupreez

Legendary member
For fixed-wing, you'll basically strip out/comment the "motors" code and use regular servo PWMs for your outputs. Nick has done a great job documenting all of this, but the provided demo code is focused on multi-rotors. Take a look at his videos and documentation, and if you have any issues you can PM me for help.
thanks for the offer