Throttle expo

Post Reply
alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Throttle expo

Post 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.

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Throttle expo

Post 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

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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).

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Throttle expo

Post 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.

marbalon
Posts: 107
Joined: Thu Aug 18, 2011 10:59 am

Re: Throttle expo

Post by marbalon »

I've tested this patch and works grate. No problems so far. Grate job!

Regards,
Marcin.

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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.

mahowik
Posts: 332
Joined: Sun Apr 10, 2011 6:26 pm

Re: Throttle expo

Post by mahowik »

Thanks a lot!!!

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

thornton
Posts: 5
Joined: Thu Mar 01, 2012 11:20 pm
Location: Berlin, Germany

Re: Throttle expo

Post 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

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Throttle expo

Post 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?

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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.

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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 :)

User avatar
howardhb
Posts: 189
Joined: Tue Oct 11, 2011 7:10 pm
Location: Port Elizabeth, South Africa

Re: Throttle expo

Post 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.

thornton
Posts: 5
Joined: Thu Mar 01, 2012 11:20 pm
Location: Berlin, Germany

Re: Throttle expo

Post 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.

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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.

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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.

Cronalex
Posts: 51
Joined: Tue Mar 20, 2012 8:41 pm

Re: Throttle expo

Post by Cronalex »

I did not understand how this change

p25o1
Posts: 33
Joined: Thu Mar 29, 2012 3:19 pm

Re: Throttle expo

Post 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

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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).

Cronalex
Posts: 51
Joined: Tue Mar 20, 2012 8:41 pm

Re: Throttle expo

Post 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

alexmos
Posts: 108
Joined: Tue Aug 09, 2011 12:12 pm

Re: Throttle expo

Post 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.

Alexinparis
Posts: 1630
Joined: Wed Jan 19, 2011 9:07 pm

Re: Throttle expo

Post by Alexinparis »

I'm currently implementing an equivalent feature with a GUI interaction.

jessestr
Posts: 86
Joined: Tue Dec 27, 2011 8:49 pm

Re: Throttle expo

Post by jessestr »

Good to hear!

Post Reply