Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/04/05 11:19
Modified:
  03/04/05 11:37

Read: times


 
#89082 - A way to implement a simple ramp down
Responding to: ???'s previous message
There is a very neat way to implement a ramp down too. This works particularly nice using byte values of parameters you are working with. Say there is a byte value that needs to be ramped to a zero value. Make a separate scale factor as a byte that is used to determine the "used" value of the byte parameter. Each time the parameter is "used" it is multiplied by the scale factor byte and then the upper 8-bits of the multiply becomes the use value. Under "normal" operating conditions this scale factor carries a value of 0xFF so that the multiply produces a used value that is the same as the parameter value. Then to implement a ramp down you establish a ramp period. The ramp period will then be series of timer interrupts that decrease this scale factor toward a zero value. If the ramp period is long then the timer interrupt period is set based on dividing the ramp time by 256 and each timer interrupt the scale factor is simply decremented. For shorter ramp periods the scale factor range (256) is divided by the available number of timer interrupts, which will be at a fixed rate, to arrive at a step size for the scale factor. Under these conditions the scale factor is decreased by this step size at each timer interrupt.

Michael Karas

//edit addition//
This scheme works nicely such that the "parameter value" can be at any level and the ramp down to zero takes place over a constant interval. The scheme can also be used to implement a ramp up process as well. I have used this to provide a soft start / stop for instance. If your algorithm has the bandwidth for higher resolution maths then then the scheme is just as applicable to 16 bit parameter values still with keeping a simple byte sized scale factor. In this instance the 16-bit parameter value is multipled by the 8-bit scale factor into a 24-bit product. The upper 16-bits of the 24 become the used value of the parameter.

Another note. In the case of the long time period ramp (where the scale factor is simply incremented or decremented in steps of 1) it may be that you still have a fixed period timer interrupt and instead the +1 or -1 steps of the scale factor are taken at the appropriate N timer interrupts as opposed to modulating the timer interrupt interval.

MJK





List of 7 messages in thread
TopicAuthorDate
Clearing the display...            01/01/70 00:00      
   Infinite loops            01/01/70 00:00      
   SLOWEST speed ?            01/01/70 00:00      
   Andy / Steve..            01/01/70 00:00      
      But wait, there's more!            01/01/70 00:00      
   One method..            01/01/70 00:00      
      A way to implement a simple ramp down            01/01/70 00:00      

Back to Subject List