writing exponential into servo code

Hi I would like to write some basic exponential into my servo code,
similar to what can be programmed on r/c computer radios.
I would still like to map my analog input 0 -1023 and my servo to move 0 - 180 degrees
but in the middle of the potentiometer travel to have it so it softens the effect it has of the movement of the servo.
I have looked around and not had any luck finding what i need.
I hope someone may be able to help me.

here's some Awk code for skewing a curve

function cubic (min, mid, max, col)  {
    Sd2 = S/2
    C   = min
    A   = (max - (2*mid) + min) / (S^2 - 2*(Sd2^2))
    B   = (max - min - A*(S)^2) / S

    printf "\n"
    printf "# min %4d, mid %4d, max %4d\n", min, mid, max
    printf "#   A %4.2f,   B %4.2f,   C %4.2f\n", A, B, C

    printf "\nnext\ncolor=%s\n", col
    for (s = 0; s <= S; s++)  {
        printf " %6d", s
        printf " %6d", (A * s^2) + (B*s) + C
        printf "\n"
    }
}

Hi,

You could do a quick and simple method.
Use the map function, 3 times.
First to map 0 joystick to where you want to start soft response. fast resp
Second map start of soft response to end of soft response, soft resp
Third map end of soft respsonse to 1023, fast resp

Something like this.

servoangle =map(analogin,0 , 340, 0, 75); // fast respsonse 0 to 340 = 0 to 75 .... 340/75 = 4.5 counts per degree
servoangle =map(analogin,341 , 684, 76, 104); // soft response 341 to 684 = 76 to 104 .... (684-341)/(104-76) = 12.2 counts per degree
servoangle =map(analogin,685 , 1023, 105, 180); // fast response 854 to 1023 = 105 to 180 .... (1023-685)/(180-105) = 4.5 counts per degree

I have chosen 340 counts at 75deg and 685 counts at 105deg as just an example.
This places the joystick centre of 512 counts still at 90deg servo.
This has not been tested, but worth a try in a simple code.

Hope that explains it?

Tom... :slight_smile:

Thank you for your replies i will give them a go.
I do understand what you are explaining Tom and it would very suitable.

you could also have a look at quadratic Bézier curves

or higher-order curves