0

I want to simulate a welcome/goodbye state on some leds. Firstly, i tried to use a linear math function and it worked but not as excepted. I want a "lower" curve(chart) climb, such as exponential function chart. I used a exponential function, and now, the higher PWM values ( pwm value is like the % of the luminous intensity of the leds) are increasing too much from one to another. So i need to modify the exponential function from 2^x in something else, so i can have a lower rate of chart growing.

i need to work with values from 0 - 65535 ( % values ) i.e . 32767 is 50% if the luminous intensity, 65535 is 100% ...

Do you have any suggestion of an exponential function with a lesser degree of growth?

2
  • 3
    I'm voting to close this question as off-topic because it's not about programming, it's about math. You may be able to find some help with this sort of thing on Mathematics.
    – David Z
    Jan 25, 2017 at 8:30
  • at this moment am in trying to use the exponential function : a*(1.1)^x Jan 26, 2017 at 8:46

1 Answer 1

0

Seems you need value 0 at time 0 and value VMax at time TMax. Note that exponential function is 1 at t=0, so you can use form

F(t) = A * Exp(k * t) - 1

You have one border condition F(0) = 0 - it is fulfilled automatically. The second condition F(TMax) = VMax. But to determine both coefficients - A and k, you need some intermediate point and define value there. For example, you can define value at half range. So

F(TMax) = A * Exp(k * TMax) - 1 = VMax
F(TMax/2) = A * Exp(k * TMax/2) - 1 = VHalf
A * Exp(k * TMax) = VMax + 1
A * Exp(k * TMax/2) = VHalf + 1
divide these equations
Exp(k * TMax/2) = (VMax + 1) / (VHalf + 1)

so coefficients are
k = 2 * Ln((VMax + 1) / (VHalf + 1)) / TMax
A = (VMax + 1) / Exp(k * TMax)

Perhaps you would use simpler approach - power function F(t) = A * tN. For example, quadratic function F = A * t * t

6
  • I folowed your sugestion and it worked ! thank you ! Now, i want to manage a parameter in the formula which will determinate the period of time that will take to rich the VMax. Something like, if i set the parameter equal to 4 seconds, the algorith will send the last value(VMax) after exactly 4 seconds. Do you have any sugestion ? Feb 3, 2017 at 7:51
  • VMax is reached at TMax time, so just set TMax = 4
    – MBo
    Feb 3, 2017 at 10:07
  • I need the VMax to be constant, and the TMax modifying the time till max value. Feb 6, 2017 at 6:59
  • If you modify TMax, just recalculate coefficients k and A
    – MBo
    Feb 6, 2017 at 7:03
  • the coefficient k must be set by me, at the beginning of the function. Feb 6, 2017 at 9:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.