Speed Limit AUX?

Discussion in 'Custom Programming' started by Dural_, Dec 16, 2016.

  1. Dural_

    Dural_ Member

    Greetings fellow pilots,

    So I recently finished making my second quadcopter, It's smaller and smoother than the previous one. Everything's well and it works perfectly, But, Since the only open flying space I can use is the school gym (I'm actually 16, I gave fake birth dates just to pass the age restrictions if there were any, sorry), So I was wondering if I can fly it indoor? I was thinking about an AUX, like Indoor mode, and Outdoor mode, While the indoor mode has limited speed, so I can easily fly it without worrying about crashing it into a family picture or someone's head. Is it possible to have an AUX which limits the max values of throttle/yaw/pitch/roll? I would be extremely grateful if someone could help me with this. Sorry if I'm in the wrong Category.

    F.I.Y: My copter is powered with Arduino, and I'm using Multiwii's firmware.
  2. Jackson

    Jackson USA member at large

    What transmitter do you have?

    I use a FlySky i6. On mine the top left switch toggles 2 choices (sport and normal) for adjustable dual rates and expo. It can adjust AIL, ELEV and YAW. On my right top switch is Throttle Hold which can also toggle on/off the settings you choose. I use mine for a simple on/off switch, it's set to full or off (o%). There is also Throttle Curve setting where you can cap your speed and also smooth out any twitchiness around the midpoint. This for me is a global setting that can't be toggled. Most flight controllers also have a myriad of tweaks/adjustments that can be made for each flight mode.

    Most of my flying this summer has been with my inexpense, abused, foam delta wing plane. With no FC the options available on the TX has worked out well and enable me to make quick adjustments in the field.
    Gyro Doctor and Dural_ like this.
  3. Dural_

    Dural_ Member

    Hey, Thanks for the response.
    I have RadioLink T8FB (8CH), It's a decent transmitter, But what I fear, Is that I don't think it's transmitter related. One of the reasons for me to be proud of my copter, Is the fact that almost everything is home-made, The frame and the props are 3d printed and instead of a flight controller I've used Arduini, Which means no matter my transmitter the AUXs won't work unless I program to do so. I really would love to have all of those cool stuff on my copter too but I don't know how am I supposed to program the AUXs.

  4. Dural_

    Dural_ Member

    Should I give up on it?
    I'm working on my other drone right now [The bigger one], and It's much faster that the one I embedded in the previous post.
    So I really need that speed limit AUX/Setting or I won't be able to train.
    Much appreciated.
  5. GJH105775

    GJH105775 Avid Linux User, and USAF 1C6 Moderator

    If you use cleanflight you can set limits on the roll and pitch axis, and then even add a varible switch to adjust that limit in flight.

    To learn to fly I'd suggest getting a smaller toy grade copter to learn on as it is much cheaper if you crash and is less likely to injure someone if you crash into them.

    Can you post the code you used for the arduino? If you did the programming for it it should be a very simple modification in the code to limit max roll, aand max pitch. If you used some other code can you post the source?

    Need more info on the build you are using and a parts list.
  6. Dural_

    Dural_ Member

    No, I am not using cleanflight, and no It's not my own code, I only had to alter it to match my quad. As I mentioned before, I'm using "MultiWii 2.4", Oh and I am looking for some way to switch it with AUX, not to have it as a default. [I want to be able to switch it from fast to slow [Indoor/Outdoor] while flying]

    That's a good suggestion and in fact, I do have a cheaper quad, but being small is not to my advantage since I can fly that one just fine but I need to get used to this bigger dude [DJI F450 frame], But there's no room for error while flying with this big guy, one wrong move and I could behead myself. lol.
    Aside from that, I think the coding is supposed to be fairly simple for someone who's familiar with it. It's supposed to be a flight mode in which the PID values change into something rather more ... friendlier.
    So far I've managed to add a new flight mode, but only by poking around the codes and simply adding a new name, I don't think it has a proper programming behind it since I can't switch to it and haven't defined it anywhere. [Mind the INDOOR mode right under HORIZON], and there are my PID values,
    If possible could you also suggest values for a friendlier quad?

  7. GJH105775

    GJH105775 Avid Linux User, and USAF 1C6 Moderator

    Being as you are using multiwii you should be able to just change the max_angle_inclination variable to be more restrictive as a hard limit, this would limit verticle speed a lot more. Then you could change the stick range, rates and expo to better tune it for your radio and skill level. After that is done adjusting the throttle midpoint will likely help with maintaining control.

    Here is a list of variables

    Here should be some helpful reading for your problem:

    This should help with the end points

    If you have not already setup the auto-level:
    Last edited: Mar 19, 2017
    Gyro Doctor likes this.
  8. How about using smaller props with shallow angle and less powerful battery,..
  9. Dural_

    Dural_ Member

    Hey, Thanks for the great hint! I couldn't find a variable with the exact name that you stated, but I managed to find this scrap of code in the multiwii.cpp file :
      // PITCH & ROLL
      for(axis=0;axis<2;axis++) {
        rc = rcCommand[axis]<<1;
        error = rc - imu.gyroData[axis];
        errorGyroI[axis]  = constrain(errorGyroI[axis]+error,-16000,+16000);       // WindUp   16 bits is ok here
        if (abs(imu.gyroData[axis])>640) errorGyroI[axis] = 0;
        ITerm = (errorGyroI[axis]>>7)*conf.pid[axis].I8>>6;                        // 16 bits is ok here 16000/125 = 128 ; 128*250 = 32000
        PTerm = mul(rc,conf.pid[axis].P8)>>6;
        if (f.ANGLE_MODE || f.HORIZON_MODE) { // axis relying on ACC
          // 50 degrees max inclination
          errorAngle         = constrain(rc + GPS_angle[axis],-500,+500) - att.angle[axis] + conf.angleTrim[axis]; //16 bits is ok here
          errorAngleI[axis]  = constrain(errorAngleI[axis]+errorAngle,-10000,+10000);                                                // WindUp     //16 bits is ok here
          PTermACC           = mul(errorAngle,conf.pid[PIDLEVEL].P8)>>7; // 32 bits is needed for calculation: errorAngle*P8 could exceed 32768   16 bits is ok for result
          int16_t limit      = conf.pid[PIDLEVEL].D8*5;
          PTermACC           = constrain(PTermACC,-limit,+limit);
          ITermACC           = mul(errorAngleI[axis],conf.pid[PIDLEVEL].I8)>>12;   // 32 bits is needed for calculation:10000*I8 could exceed 32768   16 bits is ok for result
          ITerm              = ITermACC + ((ITerm-ITermACC)*prop>>9);
          PTerm              = PTermACC + ((PTerm-PTermACC)*prop>>9);
    Knowing that the default angle inclination for the Horizon/Angle mode is 50 degrees, then could I simply change the 500 to 200? [I could do that and test it out but I'm short on propellers]

    Well. the whole point is getting used to piloting the drone, If I did as you said, then it wouldn't be the same drone that I was wishing to master, would it?
    I'm thinking about software alterations.
  10. Gyro Doctor

    Gyro Doctor Electronics Tech for over 45 years

    It's been decades since I've done any programming, but you might also have to alter the "error angle, -1000, +1000"
    term proportionally too ;)

    I'd leave your code alone though and just tweak the settings in MultiWii like
    GJH105775 suggested :)
  11. Dural_

    Dural_ Member


    I did change it to 200, but It did not differ, I figured that the same line I also used again a bit further down, so I altered that one to 200 too.
    But still, No changes, the quad still does crazy moves when pitching/rolling.

    I guessed that that line meant that, if the quad does a pitch/roll with an angle of 100 or greater the gyro will freeze? Am I wrong?
    If I am to alter it, to what value should I?
  12. Gyro Doctor

    Gyro Doctor Electronics Tech for over 45 years

    Reduce to 6400
    Reduced to 200 (done)
    Reduce to 4000

    Just a thought that ALL the terms in that loop might need to be reduced in the same proportion
  13. Dural_

    Dural_ Member

    Thanks for the numbers,
    I uploaded the new code, But again, It was not different from the other flights, The angel was still sharp, It almost seems like that these lines aren't being applied.
    [Tho, Yesterday and today, I had a crash with my quad with the new code, It flew well but at some point, it did an 180-degree flip and crashed on it's back. But there were no damages since it crashed on it's back and the propellers did not make contact with the ground, But still it flipped on it's own and that's odd, I don't know if it's related to the new code or not?]
  14. Gyro Doctor

    Gyro Doctor Electronics Tech for over 45 years

    Hard to say, but if I were you I'd return all those lines of code back to their original values ... It would be much more
    preferable returning the code to "base line" and limiting the quad through MultiWii for different flight modes than to
    alter the code's root derivatives ;)
  15. Dural_

    Dural_ Member

    Yup, I returned the code to It's original form, Guess I'll give up on the speed limit [For now at least], and learn to fly.
    Thanks for your guidance, Perhaps one day I'll know how and share it here.
  16. Gyro Doctor

    Gyro Doctor Electronics Tech for over 45 years

    You can still set a "speed limit" and also "tame" the flight characteristics of the quad by simply
    making adjustments in MultiWii, like GJH105775 said o_O

Share This Page