who know the algorithm for exponential curve in RC. - RC Groups
Jun 20, 2012, 03:40 AM
Registered User
Help!

# who know the algorithm for exponential curve in RC.

Hi, guys:
I'm building a radio control transmitter, software is going to be finished. But i encounter a hurdle. I don't know the algorithm for exponential cruve. In RC system, when we input a number that range from -100% to + 100%,we can see a exp curve in the LCD screen, can anybody impart the exponential algorithm to me? Thank you very much.
 Jun 20, 2012, 12:11 PM Registered User
 Jun 20, 2012, 10:09 PM Registered User Thud_Driver: Thank you very much! I am about to have a try!
Jun 22, 2012, 04:47 AM
Registered User

# Here is my test reoprt after reading the theads given by Thud_Driver

Hi!
Here is my test reoprt after reading the theads given by Thud_Driver, thank Thud_Driver.
At first, I used pmackenzie's measurements data to plot a 6 points curve(just for test, no so smooth). His data is

from his 9303 and a Datamaster servo tester. This time I only test 100% Expo value. Here is pmackenzie's data, the

unit is ms.
linear: 1.50,1.60,1.70,1.80,1.90,2.00
+100%: 1.50,1.50,1.53,1.59,1.71,2.00
I think it is the curve from real product's raw data. so I use it as a standard for comparing later. Green curve is

data.

Then, I used 4 main formulas from relevant threads to plot 4 curves. To my surprise, these 4 curves from diffrent

formulas almost coincide. They coincide very very well, so for a clear plotting, I only plot a red curve representing

all 4 formula results. Below are 4 formulas:
1. Thud_Driver's formula:
Y = (Exp/10)E-05X^3 - 1E-16X^2 + (1 - Exp/100)X + 2E-13
(Where x = stick throw, 0 to 100 and y = output, 0 to 100 and Exp = the expo in units (i.e., 25% = 25) )
2. mmormota's formula:
y = (x*x*x * (k-1) + x ) / k
(Where -1 < x < +1, k = 1, 1.5, 2, 3, 5...100)
3. Gord_W's formula:
y = a * x^3 + (1-a) * x
(Where 0 <= a <= 1
4. flieslikeabeagle's formula
t_out = 1.5 + A*(t_in - 1.5) + B*(t_in - 1.5)^3 ----->(1)
B = 4(1-A) ------->(2)
A = 1 - 0.25*B -------->(3)
(Where t_in is the incoming pulse width (varying between 1 mS and 2 mS), t_out is the output pulse width with the

same range)

My conclusion:
Curves from formulas and curve from measurements data coincide in some ranges.
Formulas can be used in some case, but they don't fit the real data perfectly, take it or leave it.
Establishing a lookup table using measurements data is another option.
Jun 27, 2012, 09:48 PM
Got shenpa?
Quote:
 Originally Posted by StallManeuver 4. flieslikeabeagle's formula t_out = 1.5 + A*(t_in - 1.5) + B*(t_in - 1.5)^3 ----->(1) B = 4(1-A) ------->(2) A = 1 - 0.25*B -------->(3) (Where t_in is the incoming pulse width (varying between 1 mS and 2 mS), t_out is the output pulse width with the same range)
Wow, I didn't expect to see that formula re-surface on RCG! It's been a long time!

FYI, I was looking for the simplest function that would look like the generic graphs we've all seen showing what "expo" does. Keeping in mind that this might be implemented on low-powered hardware and math functions would likely have to be implemented from scratch, I decided to simplify exponential functions to only the lowest order terms, i.e. linear and cubic.

As hardware (microcontrollers) continue to get more and more powerful, it is probably now practical to implement more sophisticated functions. In particular, I think the tanh() and sinh() functions are worth investigating. It looks to me as though the sinh function is what we want for "soft around the centre" exponential, and tanh looks like the way to get the opposite behaviour.

It would be interesting to represent sinh and tanh as polynomials, keep only the first two or three terms, and see what comes out of that.
Quote:
 Originally Posted by StallManeuver Formulas can be used in some case, but they don't fit the real data perfectly, take it or leave it. Attachment 4956620
It looks to me like you need higher order terms to get a formula that matches your example of real data from a real transmitter (note the tighter curvature of the "real data" curve, corresponding to a higher order term in the polynomial).

Most likely including the x^5 term in addition to the x and x^3 terms I used would do the trick.

As a corollary, I think the reason why all the formulae you looked at agreed with each other is this: all of them are essentially cubic representations (i.e to order x^3) of exponential functions with the same boundary conditions.

-Flieslikeabeagle
Last edited by flieslikeabeagle; Jun 29, 2012 at 05:40 PM. Reason: Got sinh() and tanh() interchanged by mistake in one place.
 Jun 28, 2012, 12:35 AM Registered User Actually, I tried higher order fits when curve fitting the data I took from the transmitter and the 3rd order fit nicely enough. In fact, I just went back to the original spreadsheet and did a 5th order fit and it was some improvement on some of the data. Considering that taking data from the Tx doesn't get data as precise as you'd like, I thought the "simplified" 3rd order polynomial was good enough.
Jun 28, 2012, 07:10 PM
Got shenpa?
Quote:
 Originally Posted by Thud_Driver I thought the "simplified" 3rd order polynomial was good enough.
I agree, I can't see that the exact shape of the curve matters all that much, especially when you already have one variable (the amount of "expo") to tweak the curve to suit pilot preference.

Actually my personal preference is for no "expo" at all. I simply adjust the full-deflection control throws to give the model the roll, yaw, and pitch rates I want. With no expo, the controls feel much more precise and linear to me, and this approach works well for the kind of flying I do, though I have no doubt it wouldn't work for extreme 3D flying.

-Flieslikeabeagle
Jun 29, 2012, 11:11 AM
Registered User
Quote:
 Originally Posted by StallManeuver ...Establishing a lookup table using measurements data is another option...
Thanks for posting the info.

If it help, the MultiWii has some expo control called RC rate in the GUI. It also uses a look up table last time I heard.