Make an acceleration/deceleration ramp : any ideas?


Results 1 to 14 of 14

Threaded View

  1. #9


    Did you find this post helpful? Yes | No

    Default Re: Make an acceleration/deceleration ramp : any ideas?

    Quote Originally Posted by Charles Linquis View Post
    I don't know how fast your ramp needs to be - but..

    I would use a timer interrupt - say 1 millisecond

    Multiply ramp time (in seconds) X 1000 to get the number of steps
    Take

    (endvalue - startvalue)/numberofsteps to get step size
    Initialize a counter with the start value and increment the step size in each interrupt.

    Depending on your needs, you may have to add some extra increments, because the step size will be an integer, and when multiplied by the number of steps may not exactly equal the
    end value.
    My maximum acceleration slope is incrementing a variable from 0 to 1200 in one second with a resolution of 1 (steps of 1).

    I've tried to "translate" your algorithm into this :


    'Variable init
    freq var word
    maxfreq var word
    minfreq var word
    stepnum var word
    stepsize var word
    time var word

    'Variables def
    minfreq=10
    maxfreq=1200
    time=10

    'Calculate steps
    stepnum=time*1000
    stepsize=(maxfreq-minfreq)/stepnum

    'Init counter
    freq=minfreq

    main:

    ' Counter
    freq=freq+stepsize

    'Update LCD
    lcdout $fe,$2,"Frequency: ",dec5 freq

    ' 1ms time base (simulates an interrupt)
    pause 1

    goto main


    It is correct? Because the result of "stepsize" is a float in this case (0.119)...
    Last edited by pxidr84; - 2nd April 2011 at 14:30.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts