This program generates a velocity profile for milling CNC in light of S-curve calculations. It is available to process linear and circular phases. There are many papers and books about the generation of S-curve velocity profiles but I couldn't find a detailed solution. Therefore, I code this program with references to these papers and books.
S-curve (aka. jerk-limited trajectory generation algorithm) is used to smooth velocity and acceleration profiles by considering the jerk. The kinematic time profiles of jerk (J), acceleration (a), feed rate (
Figure.1 Kinematic profile for jerk-limited feed rate generation
Before the NC block motion is started, the initial and final values of position
where
where the initial displacement is
and similarly, considering that the final feed (
The total number of interpolation steps (N) is checked first. If 2<N<=4, then N=4 is selected to guarantee at least the presence of the acceleration and deceleration phases (1,3,5, and 7) in Fig.1. If N<=2, then N=2 is selected to allow acceleration and deceleration. These conditions would only occur when the motion is very small, such as in high-speed spline interpolation applications or precision positioning. If the acceleration stage exists, the desired feed (
If this equation does not hold, then the magnitude of the acceleration must be reduced to its maximum possible limit as
and
The above introduction is referenced from "Manufacturing Automation" written by Yusuf Altintas.
In my opinion, the above equations can be simplified as follows:
where La and Ld are calculated as follows:
and:
Here,
Figure.2 Velocity schedule flow chart
First, A, J,
After that, if
Then, in order to solve
considering the following boundaries and constraints:
The cases of
Figure.3 Two successive blocks with different directions
The acceleration at the corner is computed by:
where,
The above content is referenced from Chapter 4 in "Theory and design of CNC".
Moreover,
Figure.4 Chord Error
Then, Jerka, Jerkd, Acc, Dec should be re-calculated.
Figure.5 presents an example. The G code program and its interpreted target program have been uploaded.