Page 1 of 1

Throttle expo

Posted: Sun Aug 21, 2011 10:21 pm
by alexmos
It is very hard to get stable altitude with my TX because it has no programming throttle curve. I think it is possible to add expo curve to the board to have more precise throttle near hover.
What we need: expo settings (already exists) and two #defines: ENABLE_THROTTLE_EXPO and THROTTLE_HOVER ( can be measured in gui). Also, throttle range may be shifted down because now 1/2 of the current range used to just start from earth.

I want to try to implement such things.

Re: Throttle expo

Posted: Mon Aug 22, 2011 9:01 pm
by alexmos
After a hours of debugging (this is my first lines of code for Arduino :)) a compact working solution was born:

In MultiWii.pde:

Code: Select all

    rcCommand[THROTTLE] = MINTHROTTLE + (int32_t)(MAXTHROTTLE-MINTHROTTLE)* (rcData[THROTTLE]-MINCHECK)/(2000-MINCHECK); 


replaced to:

Code: Select all

  #ifdef THROTTLE_EXPO
    uint16_t tmp;
    /* map x=[MINCHECK..SHIFT_HOVER..MAXCHECK] to [0..500] */
    if(rcData[THROTTLE] < SHIFT_HOVER) {
      tmp = 500 - (uint32_t)(max(rcData[THROTTLE], MINCHECK) - MINCHECK)*500/(SHIFT_HOVER - MINCHECK);
    } else {
      tmp = (uint32_t)(min(rcData[THROTTLE], MAXCHECK) - SHIFT_HOVER)*500/(MAXCHECK - SHIFT_HOVER);
    }
    uint16_t tmp2 = tmp/100;
    uint16_t y = lookupRX[tmp2] + (tmp-tmp2*100) * (lookupRX[tmp2+1]-lookupRX[tmp2]) / 100;

    /* map y=[0..500] to [1000..THROTTLE_HOVER..2000] */
    if (rcData[THROTTLE] < SHIFT_HOVER) {
      rcCommand[THROTTLE] = 1000 + (uint32_t)(500-y) * (THROTTLE_HOVER - 1000) / 500;
    } else {
      rcCommand[THROTTLE] = THROTTLE_HOVER + (uint32_t) y * (2000 - THROTTLE_HOVER) / 500;
    }
  #else
    rcCommand[THROTTLE] = MINTHROTTLE + (int32_t)(MAXTHROTTLE-MINTHROTTLE)* (rcData[THROTTLE]-MINCHECK)/(2000-MINCHECK);
  #endif


Add to config.h:

Code: Select all

/* You can enable throttle expo curve near hover point, affected by 'EXPO' AND 'RC RATE' setting in GUI */
/* It is recomended to test it in GUI with your receiver before fly */
#define THROTTLE_EXPO
/* Throttle value just before copter start flying (expo zero point will be here) */
/* Should be measured in GUI with full copter load. */
#define THROTTLE_HOVER 1500
/* You can shift hover point to the begining of the throttle range to use more of remaining range to fly */
/* 1500 - no shift */
#define SHIFT_HOVER 1500


Now throttle bar looks fine in GUI in middle range. But aware, I was not flying with it.

Re: Throttle expo

Posted: Tue Aug 23, 2011 7:48 am
by crashlander
It is possible to use TX in Helli mode CCPM (one servo). That way you get normal helli like throttle curve which is probably easier to modify "on the fly"!

Andrej

Re: Throttle expo

Posted: Tue Aug 23, 2011 4:59 pm
by alexmos
I have cheap TX (HK-T6A) - all configuration made trough PC. I tryed to get desired curve from it but no success, so I finally leave it in acro mode (all channels are linear).

Today I did field tests, result is very good - it is much more easier to hold altitude. So, this mod will be helpfull for those who own TX without throttle curve setting (or can't set it).

Re: Throttle expo

Posted: Tue Aug 23, 2011 7:47 pm
by copterrichie
Heli-90 would be best in my opinion. It function as Acro but you get the usage of the Throttle Curve without any mixing.

Re: Throttle expo

Posted: Mon Aug 29, 2011 1:27 pm
by marbalon
I've tested this patch and works grate. No problems so far. Grate job!

Regards,
Marcin.

Re: Throttle expo

Posted: Mon Sep 12, 2011 8:58 pm
by alexmos
I have a final correction of my code: 1000 and 2000 values should be replaced to the MINTHROTTLE and MAXTHROTTLE to extend usefull range of throttle (we assumed that ESC should not accept values outside this range).

Also, expo curve from GUI contains the rcRate multiplier, wich decreases min and max values of controller. I think it is not needed in the throttle stick.

Code: Select all

  #ifdef THROTTLE_EXPO
    uint16_t tmp;
    /* map x=[MINCHECK..SHIFT_HOVER..MAXCHECK] to [0..500] (expo without rcRate) */
    if(rcData[THROTTLE] < SHIFT_HOVER) {
      tmp = 500 - (uint32_t)(max(rcData[THROTTLE], MINCHECK) - MINCHECK)*500/(SHIFT_HOVER - MINCHECK);
    } else {
      tmp = (uint32_t)(min(rcData[THROTTLE], MAXCHECK) - SHIFT_HOVER)*500/(MAXCHECK - SHIFT_HOVER);
    }
    uint16_t tmp2 = tmp/100;
    uint16_t y = (lookupRX[tmp2]*50 + (tmp-tmp2*100) * (lookupRX[tmp2+1]-lookupRX[tmp2]) / 2 ) / rcRate8;

    /* map y=[0..500] to [MINTHROTTLE..THROTTLE_HOVER..MAXTHROTTLE] */
    if (rcData[THROTTLE] < SHIFT_HOVER) {
      rcCommand[THROTTLE] = MINTHROTTLE + (uint32_t)(500-y) * (THROTTLE_HOVER - MINTHROTTLE) / 500;
    } else {
      rcCommand[THROTTLE] = THROTTLE_HOVER + (uint32_t) y * (MAXTHROTTLE - THROTTLE_HOVER) / 500;
    }
  #else
    rcCommand[THROTTLE] = MINTHROTTLE + (int32_t)(MAXTHROTTLE-MINTHROTTLE)* (rcData[THROTTLE]-MINCHECK)/(2000-MINCHECK);
  #endif 


I have tested it and it works well.

Re: Throttle expo

Posted: Thu Oct 13, 2011 12:46 am
by mahowik
Thanks a lot!!!

It's really helps to keep stable altitude now with my Hobby King 2.4Ghz 6Ch Tx!

Re: Throttle expo

Posted: Mon Mar 19, 2012 7:36 pm
by thornton
First, thanks a lot for this wonderful program multiwii to everybody developing it!
Throttle_expo helped me very much as a beginner and i wood like to use it again.

I have just a short question:
Is it still save to use throttle_expo with the latest versions of 2.0?

Thanks in advance

Re: Throttle expo

Posted: Mon Mar 19, 2012 9:56 pm
by howardhb
Sounds like a very usefull mod. I will try this soon too. (V2pre2)
While flying in level mode with Baro activated yesterday (taking gopro video footage) I found it difficult to maintain constant height because necessary Yaw stick movements invariably apply small but significant throttle changes.
I must say that the Baro function is working fine, -+ 0.3m

I applied the mod suggested by nhadrian to zero BaroAlt when motors are armed.(ground level)
viewtopic.php?f=8&t=1351
So, if Baro is activated on the ground, the throttle stick could then control actual altitude from ground-level (low trottle) to a Max altitude, say 50m (max throttle), defined in Config?

Thoughts?

Re: Throttle expo

Posted: Tue Mar 20, 2012 8:06 am
by alexmos
Hi howadhb! You question is outside of this topic, because throttle expo does not control altitude, it just helps to get more precise throttle stick in the range of flight.

You question is more related to AltHold mode. In this mode, in my vision, throttle must switch to altitude control, as you wrote. I have implemented it for myself, but don't know how it is implemented in V2.

Re: Throttle expo

Posted: Tue Mar 20, 2012 8:11 am
by alexmos
thornton wrote:First, thanks a lot for this wonderful program multiwii to everybody developing it!
Throttle_expo helped me very much as a beginner and i wood like to use it again.

I have just a short question:
Is it still save to use throttle_expo with the latest versions of 2.0?

Thanks in advance


I have not tested this mod with v2 (have a lack of time to merge all my code with v2) but I think it has 99% chance to be compatible. You can try it in GUI before flight to see it still working :)

Re: Throttle expo

Posted: Tue Mar 20, 2012 10:33 am
by howardhb
Hi @alexmos.

Yes, I realise that expo (around the hover throttle point) will greatly improve altitude control (by the pilot) when Baro is not active.
(meaning, less sensitive to small changes to throttle stick, when applying yaw inputs)
Would you share your code for throttle stick altitude control when Baro is enabled?
I will merge it (if possible) with V2pre4 and post my experience.

Cheers
H.

Re: Throttle expo

Posted: Tue Mar 20, 2012 10:06 pm
by thornton
I tried it today in acro and in stable mode (2.0 pre 3). Wonderfull!.
It makes life easier for beginners! Should be for everybody, not only coders!
Thanks a lot.

Re: Throttle expo

Posted: Wed Mar 21, 2012 10:26 am
by alexmos
howardhb wrote:Hi @alexmos.
Would you share your code for throttle stick altitude control when Baro is enabled?
I will merge it (if possible) with V2pre4 and post my experience.
Cheers
H.


Yes, but there are few errors in my code. I will finish them soon and share revision r16 after some testing. After that, I will merge with 2.0.

Re: Throttle expo

Posted: Wed Mar 21, 2012 10:28 am
by alexmos
thornton wrote:I tried it today in acro and in stable mode (2.0 pre 3). Wonderfull!.
It makes life easier for beginners! Should be for everybody, not only coders!
Thanks a lot.


I am beginner, too :) I had made this mod after some unsuccesfull attempts to get altitude under control with my simple Tx.

Re: Throttle expo

Posted: Sun Apr 08, 2012 7:58 am
by Cronalex
I did not understand how this change

Re: Throttle expo

Posted: Mon Apr 16, 2012 12:03 am
by p25o1
alexmos wrote:
howardhb wrote:Hi @alexmos.
Would you share your code for throttle stick altitude control when Baro is enabled?
I will merge it (if possible) with V2pre4 and post my experience.
Cheers
H.


Yes, but there are few errors in my code. I will finish them soon and share revision r16 after some testing. After that, I will merge with 2.0.


hi alexmos,

i was looking for this option in multiwii, and i found your post, great work,

i want to use it on my setup, but i'm also using alt hold.

will it work ok with alt hold? and is it part of the new multiwii 2.0 update, or i have to install it and update my firmware ?

thx for this mod, i hope it gets imported to the full release :-) we all need some throttle help to stop bouncing lool

Re: Throttle expo

Posted: Mon Apr 16, 2012 3:48 pm
by alexmos
Hi,
This mod can be inserted into 2.0 and works well. Yes, it works with Alt Hold mode, too.

You should manually insert code into MultiWii.ino and config.h (see posts above).

Re: Throttle expo

Posted: Mon Apr 16, 2012 4:55 pm
by Cronalex
with parameters that should make the expo to have a good throttle curve?

my default
rc rate : 0.90
expo: 0.65
MINTHROTTLE: 1200
MAXTHROTTLE:1850

Re: Throttle expo

Posted: Tue Apr 17, 2012 12:53 pm
by alexmos
With your expo=0.65 throttle will be very smooth (I have used the same in the begining). Only remember to set THROTTLE_HOVER to value where you copter takes from the ground (for that, connect GUI and see throttle level in the hovering). SHIFT_HOVER may be the same as THROTTLE_HOVER or set it about 1500.

Re: Throttle expo

Posted: Sun Apr 22, 2012 5:15 pm
by Alexinparis
I'm currently implementing an equivalent feature with a GUI interaction.

Re: Throttle expo

Posted: Mon Apr 23, 2012 6:01 am
by jessestr
Good to hear!