Make an acceleration/deceleration ramp : any ideas?


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

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

    If you do not intend running any tasks in the background while doing the acc/deceleration, the following idea may work

    Code:
    Rate = ((Max-Min) *1000)/ Time   ' the 1000 is since I assume a mS time base
    Here the Time variable is specified in seconds.

    Now, using a 1mS time base, you can do this

    Code:
    for x = 0 to rate
       Output = Output + Rate  ' increase the output by a fraction we calculated
       pause 1           ' this is the 1mS time base I talked of
    next
    Rate could be -ve to decelerate.

  2. #2


    Did you find this post helpful? Yes | No

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

    Quote Originally Posted by Jerson View Post
    If you do not intend running any tasks in the background while doing the acc/deceleration, the following idea may work

    Code:
    Rate = ((Max-Min) *1000)/ Time   ' the 1000 is since I assume a mS time base
    Here the Time variable is specified in seconds.

    Now, using a 1mS time base, you can do this

    Code:
    for x = 0 to rate
       Output = Output + Rate  ' increase the output by a fraction we calculated
       pause 1           ' this is the 1mS time base I talked of
    next
    Rate could be -ve to decelerate.
    Hello,

    Thanks for your idea, I will try this into my program, but unfortunately I think that the "pause" command will make problems, because a lot of things are running in the background during this acc/deceleration (like the sine PWM generation high priority interrupt, using timer 1).

    I think use this in a low frequency and low priority interrupt (with timer 0), maybe the "pause" command will be useless?

    Note I'm using Darrel Taylor's interrupts.

  3. #3
    Join Date
    Oct 2005
    Location
    Pinckney, Michigan
    Posts
    91


    Did you find this post helpful? Yes | No

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

    My approach would be to generate the "points" you need for the line equation, given your slope and time parameters, in Excel. Then print a CSV file of the results, then copy the CSV file into your program as a table. It'll take some minor editing to generate your table but no big deal, and get the values from the table with Lookup or Lookup2. You can even change the slope of your ramp easily by adjusting the dwell time at each point, etc.

    I do this sort of thing a lot for thermistor temperature tables, etc. Saves the time of executing the extensive formula for thermistor values.

  4. #4


    Did you find this post helpful? Yes | No

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

    Can you give more info?

    What is the motor being used for?

    How does the user change the speed?

    Typical servo systems use a PID routine.

    Henrik Olsson posted a great PID program example on the forum. As I recall the thread mentioned motors and DT interupts.

  5. #5


    Did you find this post helpful? Yes | No

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

    I don't want to use a PID routine or a lookup table (because a lookup table is hungry of program memory space). It's a open-loop inverter.

    The user changes the frequency reference by turning a potentiometer connected to a ADCIN port.

    Exemple :

    Note the acceleration and deceleration ramp of the output frequency, that changes the speed of the AC motor.

    I like to have a routine (in a low-priority interrupt for exemple, to have the most accurate timings) that increments a value from the actual output frequency (for exemple 20Hz) to the frequency reference (for exemple 60Hz, defined by the user) in x seconds (for exemple 10 seconds, can be modified in real-time), and that without using any "pause" command (because my PIC has a lot things to do during this time).
    Last edited by pxidr84; - 1st April 2011 at 17:17.

  6. #6
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

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

    You can delegate the timekeeping and ramping to the ISR. What you need to pass to it is the 'target' value and 'step size' Step Size could be +ve or -ve depending on which way you want it to move.

    the ISR could tick every millisec or maybe more depending on how fast you want to change the output.

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

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

    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.
    Charles Linquist

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