rising

hi everybody

i want to slower the variations of a measured value, not excactly average it because i need different rise an fall timings.
is there instructions for that ?

Can you put your requirements in more mathematical terms? Describe the signal to be measured? It is not clear, to me at least, what you are are really looking for.

sorry for not beeing clear!
i have an an analog input with very fast variations, i want to have an analog out of this but with slower variations.
i want to control separately the rise and fall timing.

for example: the output value can rise fast (but slower than input value) and fall in a very slow way
or reverse!

hope this will help you to understand what i mean ( i’ french and it’s quite hard for me to explain this in english)

So you would like to reproduce the effects that a capacitor, resistor, diode, or inductor circuit might have on a signal.

Your example might mimic a capacitor charging up thru a diode and then discharging only to the following circuit. You can search the playground and see if there is any modelling software that you can use.

You'll need some conversions if you are using only the ATMega hardware, the modeling software (if it exists) might take this into account. The analog inputs can sample at 8-10KHz, with 10-bit accuracy (so ~4.88mv per bit step). The analog output is a PWM signal that varies in pulse width in from 0 to 255 at ~490 HZ rate, so to get a smooth analog signal out you need to put a low pass filter on the output.

There is a piece of code, I create for led’s bar display:

   kraccums = kraccumn;  

   kraccumn = 0;  //Reset 

   kraccumn =  kraccumn + fx[count]; //Red band
   
  //Smoothing, so it fall down gradually.  
   if ( kraccumn < (kraccums * kdmp) )
     kraccumn = (kraccums * kdmp);

There are two variables ( new value kraccumn, old value kraccums) and constant kdmp, that controls falling speed.
As you can see, if new value kraccumn (would be analogread in your case) is less than old one,
than you decrease it multiply by kdmp = 0.99 (1% down in each cycle), you have to adjust
kdmp bases on how fast your software loop running, or insert delay in the loop.

For control rising time, similar solution could be implemented:

 if ( kraccumn > (kraccums * krise) )
     kraccumn = (kraccums * krise);

krise has to be more than 1, 1.01 or so.

hope this will help you to understand what i mean ( i' french and it's quite hard for me to explain this in english)

If it helps, ask your question in French - there are regular posters here who are either fluent or fake it well. Also, Google translate is your friend for those of us whose Francais is weak.

thank you Magician! that's exactly what i'm looking for and it's simple!