Convert trapezoidal velocity profile into one with s-curve

213 Views Asked by At

I am an electronic engineer. I have created a system that contains a stepper motor. There is a speed table that specifies the speed values that are to be used to accelerate and deaccelerate the motor. The speed profile is trapezoidal.

Generating a trapezoidal profile is actually quite easy since it consists of straight line segments. Doing math with straight lines is straight (pun not intended) since they can be generated using the y=mx+c graph.

I want to know how I can generate a smoother s-curve shaped speed profile instead of the trapezoidal profile. I am not at all sure where to start from. The thing is, there is no single s-shape curve since and their smoothness can vary also so I don't know what equation is used.

What topic do I search in order to determine how to convert the trapezoid into s-curve? At present I have a Python script which generates the trapezoidal values. This script will just need to be updated so it maps the trapezoid into a smooth s-curve and then I use these values in the stepper motor driver. Its just that I don't know what specific curve is suited for this scenario and what is the procedure to map it into a smoother curve.

There appear to be a lot of functions that can generate a smooth s shaped curve, these include but are not limited to:

  • Logistic function
  • Arctangent function
  • Gudermannian function
  • Error function
  • Generalised logistic function
  • Smoothstep function
1

There are 1 best solutions below

2
On BEST ANSWER

One possible thing to do is to create some smooth profile $f(x)$ with the properties you like that accelerates from speed $0$ at moment $0$ to the speed $1$ at moment $1$ and then just use its scaled versions, so if you need to accelerate from $0$ to speed $v$ between times $a$ and $b$, the formula (fot $t\in[a,b]$) is $$ V(t)=vf(\tfrac{t-a}{b-a}) $$ and if you need to decelerate from $v$ back to $0$ over the time period $[c,d]$, you set $$ V(t)=vf(\tfrac{d-t}{d-c}) $$ for $t\in [c,d]$. This makes the curves as easy to work with as straight lines but still offers you a lot of flexibility.

There is no "best in all respects" smooth ascent from $0$ to $1$ in time $1$. You should use your common sense and your physical constraints to decide which one makes most sense. However, if you just want a simple formula, try $$ f(t)=\begin{cases}2t^2 & 0\le t\le \frac 12 \\ 1-2(1-t)^2 & \frac 12\le t\le 1 \end{cases} $$ The picture with this curve looks like this:

enter image description here