Independent Tilt Rotor Support?

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Independent Tilt Rotor Support?

Post by pyronaught »

Before reinventing the wheel, I want to check if what I'm trying to do is already supported in the MultiWii code. I'm flying a quad in plus mode where each motor has it's own servo for tilting the prop angle. The servos need to be linked in pairs such that the left and right move together when the pitch stick moves and the front and back move together when the aileron stick moves. Since the servos are on opposite sides that means the movement of one would actually be reversed from the other, so the same signal could not simply be sent to each over the same wire. The purpose here is to keep the quad body level when moving laterally. The motors themselves would only be operating in self-level mode, with no reaction to stick commands other than throttle and yaw. I've seen the racer quads where all four props tilt together in the same direction, but I think only one or two servos are being used to do that since they are mechanically linked in pairs. This is a little different in that each motor has its own servo and none of them are mechanically linked.

If something like this does exist I assume there would also need to be a mode for trimming each servo independently to get them all perfectly vertical at stick center.

If something like this doesn't exist I'll have to code it myself, but I was hoping I could get out of doing all that work.

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

As starting point you need a type with 4 motors and 4 servos. This is possible but not setup yet.
From there it is only mixing stuff mostly.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

When you say not setup yet, does this mean there has to be code changes to make it happen? On the mixing side, do you mean mixing on the Tx or would that be part of the code changes that need to be added in the MultiWii? Ideally there would just be a config tem like "Quad+ tilt-rotor" or something like that to identify this particular design.

I've attached a picture of the experimental quad I need this special mode for. You can see that a big body like that (4 ft diameter) needs to be kept level when flying laterally, hence the need for tilt rotors.

version_3_sm.jpg

tilt_rotor_sm.jpg

test_flight1_sm.jpg

test_flight3_sm.jpg

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

Hamburger wrote:As starting point you need a type with 4 motors and 4 servos. This is possible but not setup yet.
From there it is only mixing stuff mostly.


I see what you are talking about now. I'm going to try this:

Code: Select all

  #define QUADP_TILT
...
  #define SERVO_RATES      {0,1,0,1,1,0,1,100}
...
#elif defined(QUADP_TILT)
  #define NUMBER_MOTOR     4
  #define PRI_SERVO_FROM   1 // use servos from 1 to 4
  #define PRI_SERVO_TO     4
...
#if defined(BI) || defined(TRI) || defined(FIXEDWING) || defined(HELICOPTER) || defined(QUADP_TILT) ||defined(SINGLECOPTER)|| defined(DUALCOPTER)
  #define COPTER_WITH_SERVO
#endif
...
  #elif defined( QUADP_TILT )
    motor[0] = PIDMIX( 0,+1,0); //REAR
    motor[1] = PIDMIX(-1, 0,0); //RIGHT
    motor[2] = PIDMIX(+1, 0,0); //LEFT
    motor[3] = PIDMIX( 0,-1,0); //FRONT   
    servo[0]  = (axisPID[YAW]*SERVODIR(0,2)) + (axisPID[PITCH]*SERVODIR(0,1));   //   Front A0
    servo[1]  = (axisPID[YAW]*SERVODIR(1,2)) + (axisPID[PITCH]*SERVODIR(1,1));   //   Back A1
    servo[2]  = (axisPID[YAW]*SERVODIR(2,2)) + (axisPID[ROLL] *SERVODIR(2,1));   //   Left A2
    servo[3]  = (axisPID[YAW]*SERVODIR(3,2)) + (axisPID[ROLL] *SERVODIR(3,1));   //   Right D12


Having all four rotors tilt on a yaw command is really going to fling it into a spin, so I'll have to change that. For now I want to see how fast it will spin just out of curiosity. I set the rotation to zero on all the motors since that is what was being done on the rear motor of a tri-copter.

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

Yes. Looking good as a starting point.

Next you must write your mixing code for 4motors plus 4 servos in output.cpp.
It is rather straight forward.

Also you must make your quad.tilt become another option and value for multicopter.type variable.
You are on the right track now.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

Here's the thing that doesn't seem compatible with the way the mixTable() setup works: my design requires the pitch and roll commands from the transmitter to be ignored in the PID calculations. But this does not seem possible using the current defines since RC commands are rolled into the calculations that are setting the axisPID[] values.

#define PIDMIX(X,Y,Z) rcCommand[THROTTLE] + axisPID[ROLL]*X + axisPID[PITCH]*Y + YAW_DIRECTION * axisPID[YAW]*Z

The way my configuration needs to work is that pitch and roll basically get treated as a straight pass-through to the servos and ignored by the PID calculations. I could almost do it by wiring them direct to the receiver, except one signal needs to be reversed due to the servos being mounted in mirror images of each other. The FC basically just operates in auto-level and only uses throttle and yaw commands for the motors. It would also be desirable to increase the throttle proportional to the tilt on any motor that is tilting, both due to the lift that will be lost as tilt increases and to make lateral speed proportional to stick position.

So it would appear to be something that can't be done from the mix table setup alone. Some conditionals would need to go into the PID calculation routine in the main loop.

Even though this scheme could probably be done using some outside method of reversing one servo signal and then running them directly from the Rx to keep from hogging up four outputs on the FC and preventing ever using a gimbal, I still want to do it this way due to another experimental spin-flight mode I'm going to try later on which requires cycling of the tilt servos in synchronization with the spin rate. Have to get the easy flight mode working first though.

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

dunno if I understand what you want to do. But you could always do things like

Code: Select all

motor[0] = rcCommand[THROTTLE];
servo[5] = (SERVODIR(5, 1) * rcCommand[YAW] + get_middle(5);

Maybe the flying.wing and helicopter mixing code will give you an idea what is possible?

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

Here's a picture that shows what I'm trying to do. The goal is to keep the body of the craft level when flying laterally, instead of tilting it in the direction of travel like how a normal quad works. So opposing sets of motors need to tilt as a pair in the direction of travel as shown in the drawing. So PID calculations still need to be applied to each motor like a normal quad in order to auto-level it, but that calculation should not incorporate any stick commands, since the stick commands will only be effecting the servos. That's the simplified version anyway, in reality the quad would start to drop once one set of motors were tilted unless throttle on the tilted motors were increased in order to make up for the thrust transferred in the forward direction. The user could manually compensate for that by giving more throttle, but ideally the FC should be able to maintain hover while flying. I'll worry about that problem next though, for now I just want to get the basic mixing for doing this mode of flying.

drawing1.jpg

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

Got it working. That's pretty cool that this code can be so easily customized for unconventional projects like this :)

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

good to hear you made it! Congratulations.
For once I will be looking forward to seeing a demonstration flight video.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

Accidentally flew it with auto-level turned off and crashed it today. Auto-level is mandatory since you have no control over pitch and roll angles. It has to stay perfectly level, otherwise if it pitches up or down in the direction of travel when moving fast then you get runaway pitch with no way to correct for it. In my case it pitched down and crashed into the ground, but it could have just as easily pitched up too. I'm hoping auto-level will have a fast enough reaction time to correct any pitch before it becomes too large, otherwise I think the forces acting on such a large surface area will be too much for the motors to overcome beyond a certain angle of attack.

I'll get some video once it is all sorted though. I have to print another motor mount and try it again tomorrow. Usually only the motor arms break on bad crashes and nothing else. I'm using 15% infill on the motor arms, so they are almost hollow. I'm going to increase that to 40% and see if they will stop breaking. It takes a pretty good hit to break one as it is, and only hits from above or below will snap them. They are very tolerant to side strikes.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

So far the thing that makes this flight mode tricky to manage is the drop in downward thrust that occurs when the rotors tilt. Full tilt can result in a pretty dramatic loss of vertical thrust and it is kind of tricky to have to always be compensating for it with increased throttle. For example, if I am hovering and bouncing back and forth side to side, each time I stop on one side the craft will shoot up, then drop once moving sideways again. So it requires constant changing of the throttle to try and do this at a level altitude. Seems like this same thing would happen with normal quad flight modes, so there must be some kind of thrust compensation that is usually done in the code that is not getting done with my custom mix.

Looks like a similar idea already exists:

/************************ Angele throttle correction ********************/
/* Automatically increase throttle based on the angle of the copter
Original idea by Kraut Rob, first implementation HAdrian */

#define THROTTLE_ANGLE_CORRECTION 40


Although in my case I would have to modify the calculation for this since the FC board is not at an angle, only the motor is. Since there is no sensor for the servo angle, it would have to be estimated based on the servo value and the max angle it can have.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

I'm getting it dialed in, it is getting easier to fly now. Here's the current mix code:

Code: Select all

 #elif defined( QUADP_TILT )
  // note that yaw is removed from all motors and placed on the rear servo
    motor[0] = PIDMIX( 0,+1,0); //REAR D9
    motor[1] = PIDMIX(-1, 0,0); //RIGHT D10
    motor[2] = PIDMIX(+1, 0,0); //LEFT D11
    motor[3] = PIDMIX( 0,-1,0); //FRONT    D3
    servo[0]  = get_middle(0) + rcCommand[PITCH]; //   M4 Left A0
    servo[1]  = get_middle(1) - rcCommand[PITCH]; //   M2 Right A1
    servo[2]  = get_middle(2) + rcCommand[ROLL] - axisPID[YAW];  //  M3 Back A2
    servo[3]  = get_middle(3) - rcCommand[ROLL];  //   M1 Front D12

   // compensate for vertical thrust that is lost when motors are tilted by increasing the throttle on the tilted motors proportional to their tilt angle 
   // formula: T2 = T1/Cos(tilt angle) where T1 is the vertical thrust component and T2 is the total thrust required to achieve it
   // max servo angle = 37 degrees at rcCommand value of 400 (rcCommand spans between around -400 and 400, with 0 being the mid point where there is no tilt angle)
   // .0016 = 37/400 * pi/180   this is the servo angle conversion and degrees to radians conversion combined into one scalar
   double pitch_thrust_scaler = 1/cos( .0016 * abs(rcCommand[PITCH]) );
   double roll_thrust_scaler = 1/cos( .0016 * abs(rcCommand[ROLL]) );
   motor[0] = (int16_t)((double)motor[0] * roll_thrust_scaler);
   motor[1] = (int16_t)((double)motor[1] * pitch_thrust_scaler);
   motor[2] = (int16_t)((double)motor[2] * pitch_thrust_scaler);
   motor[3] = (int16_t)((double)motor[3] * roll_thrust_scaler);

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

I finally got it flying in a controllable state. There's still an issue with nose dives when moving sideways too fast, so I have to keep it slow for now until I get that solved. I can also make it do a flip by cutting the throttle while moving sideways, but if it doesn't flip all the way back around then it's an upside down landing. You can cut the engines and let it drop out of the sky and it usually won't get damaged unless it comes down on its edge right where a motor mount happens to be. If it is not moving sideways it will drop straight down and just bounce off the ground.

Here's some shaky video filmed by my 9 yr old:

https://www.youtube.com/watch?v=ZUnRx5Z0ccg

User avatar
Leo
Posts: 372
Joined: Wed Sep 17, 2014 7:01 am
Location: Germany
Contact:

Re: Independent Tilt Rotor Support?

Post by Leo »

That's cool! 8-)

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

maybe you should put yaw on all 4 servos? then yaw-corrections and -inputs could maybe have less unwanted differences in vertical thrust components.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

The single yaw motor wasn't causing a problem, it was the paired tilting for pitch and roll that would create a big loss of vertical thrust. That has all been fixed now with the code I posted above. I had to disable the code for motor normalizing too, it was causing problems. The only remaining problem is how to deal with the pitch lock-in that occurs on the leading edge. There does not appear to be enough reserve throttle to overcome that beyond a certain point. I need to play with the PID settings some more to try and reign in any unlevel pitch as fast as possible before it hits the angle of no return. There were two forced landings in the video that resulted from that problem. OK, the one at the end was more of a crash than a landing :?

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

Did you callibrate the escs to your (default) throttle range?
The huge copter body works as a giant dampener against all movements of pit h roll and throttle change. If too extreme you might have to use beefier power system
If you are lucky then a high P value for roll and pitch should do the magic.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

There's plenty of room to add more motor pods, but the problem is I've got all 8 outputs occupied on the wii. I would have to stack another Wii board and then run four more motor pods of that one, configured for auto-level using just fixed rotors and ignoring all input except throttle. That would give it some serious stabilization power and lifting ability, although nearly doubling the cost. I've never heard of anyone using more than one FC though, have you? Seems like it would be possible as a way to get around the 8 output limitation and maybe even provide a form of redundancy.

User avatar
Hamburger
Posts: 2563
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: Independent Tilt Rotor Support?

Post by Hamburger »

you could try and join every two sid-by-side motors+escs and their servos and drive these from the same fc outputs.

pyronaught
Posts: 17
Joined: Sun Jun 28, 2015 4:44 am

Re: Independent Tilt Rotor Support?

Post by pyronaught »

One method would be to use one multiwii as the FC and then completely reprogram a second multiwii to act as a port expander. So the 2nd multiwii would be a dedicated pulse generator that does not do any flight control calculations and only communicates with the main FC over I2C. All it does is generate the appropriate pulse for each output pin and communicate with the main board to get the required data. The inputs of the 2nd multiwii could be reconfigured as outputs, giving it the ability to drive 16 devices for a total combined output of 24 devices between the two boards.

That would be the best solution, although also the most work due to all the software development required. Given how small and cheap the multiwii is, it is easy to buy a second one. I just picked up another one from HobbyKing for $19.74 the other day. At that price it is worth picking up a half dozen of them just to keep around for general purpose ARV stamp boards for other projects unrelated to multirotors.

Post Reply