1. Introduction
Servo drive systems are exploited widely in industries due to their efficiency, high-performance in motion control, and fast response times to dynamic reference signals [
1,
2]. In order to comply with the technological requirements, modern automatic machines have to guarantee decent dynamics for position and velocity control of motors, these servo drives solutions are utilized in Computer Numerically Controlled (CNC) machining, robotics, factory automation, and many other areas.
The most common control scheme implemented in servo drives to control position and velocity is the cascade control algorithm [
3]. Its task is to regulate current, velocity, and position of the motor in separate closed control loops, in order to minimize overshoot and reduce the influence of external disturbances.
Nowadays, an increasing number of commercial control system manufacturers provide open architecture systems [
4], meeting the need to constantly improve the servo drives functionality. This approach allows for design, testing, and integration of new control algorithms and techniques such as control laws, multi-sensor integration, or Artificial Intelligence (AI).
Simultaneously, evolution of the servo drive system programming languages is progressing. Currently, most of the commercial systems allow the user to implement custom code in the native control structure. These modifications can be written in popular programming languages such as C, C++, or Structured Text (ST).
Automatic code generation [
5] is one of the ideas which facilitates implementing the code in various industrial control platforms. It is based on text languages (C, ST) and allows to compile and transfer developed code or algorithms between devices of different classes and manufacturers with minimal effort on the programmer’s part.
In the following work, generation of motion profiles (especially position) for servo drives is considered. This is a crucial aspect of applications that demand a high motion fidelity, e.g., CNC feed drives and multi-axis manipulators. In this case, constraining the acceleration profile obtained by the second order trajectory generator leads to oscillations whenever the movement direction changes (i.e., zero crossing of set velocity). This is the main reason for using third and higher order trajectory generators, for defining constraints on jerk or snap [
6].
This paper is organized as follows:
Section 1 serves as a brief introduction to control of digital servo drives;
Section 2 is devoted to PLCopen Motion Control, particularly to one of its motion functions—MC_MoveAbsolute().
Section 3 presents a step by step algorithm to find a motion profile with boundaries defined up to the fourth derivative of position, and the trajectory generator of the fourth order is described. This topic is expanded upon in
Section 4, where a real-time calculation of the beforementioned profile is discussed. Finally,
Section 5 puts these solutions in context of the Programmable Logic/Automation Controller (PLC/PAC) devices that are IEC 61131-3 compliant, while
Section 6 summarizes the paper.
2. Trajectory Generation in Digital Servo Drives: PLCopen Motion Control
In References [
6,
7,
8,
9], trajectory generation algorithms used in motion solutions are presented. The dynamics of mechanical aspects of the systems are considered in order to develop a feedforward controller. The following work is further expanding the ideas presented in Reference [
9], such that the mathematical foundation laid there could be implemented in a real-time system.
In Reference [
10], the concept of utilizing the PLCopen Motion Control standard for controlling the digital servo drive of the CNC machine is given. In the PLCopen Motion Control standard, several states are defined that outline the operation of a digital servo drive. These states depict the actual status of the motion system, being the type of movement executed (if any), present errors, stopping, or awaiting commands from the control system. Of particular interest are the two states tied to the motion execution:
- (a)
Discrete Motion – movement to a defined position;
- (b)
Continuous Motion – movement without a setpoint (e.g., shaft rotating with set velocity).
The transition between particular states is achieved by calling related functions, e.g., MC_MoveAbsolute (absolute movement) or MC_MoveAdditive (additive moment in a specified direction). The entire state machine is presented in
Figure 1.
MC_MoveAbsolute() – Function Description
This function block starts a controlled movement to a specified absolute position. All of the parameters needed to start the movement are transferred on a rising edge of the Execute input (
Figure 2). The axis changes to the Discrete Motion state after all of them have been successfully transferred. Before the function block can be used for a real axis, the axis must be homed. States in which this function block can be used: Standstill, Discrete Motion, and Continuous Motion.
In the following figures, the timing diagrams for MC_MoveAbsolute() possible usage scenarios are shown. In
Figure 3a, the first function block (MC_MoveAbsolute_0) stopped its movement before the second function block (MC_MoveAbsolute_1) was started. In
Figure 3b, the second function block (MC_MoveAbsolute_1) was started before the first function block (MC_MoveAbsolute_0) completed its movement. In both cases, as seen in
Figure 3a,b, the movements finish in the same position.
3. Fourth Order Position Profile Generation
In this work, the position profile will be understood as a setpoint trajectory with a sampling time specified for a real-time algorithm implementation. The following convention, adopted from [
9], was used to denote the parameters:
– position, displacement (profile,
);
– velocity (profile,
);
– acceleration (profile,
);
– jerk (profile,
);
– derivative of jerk (profile,
);
,
,
,
,
– bound on
,
,
,
,
, respectively;
,
,
,
– time interval during in which
,
,
,
obtains its bound, respectively;
– sampling time in seconds.
The fourth order position trajectory generation problem was considered within this document. One input was used to define the desired position (i.e., increment from an actual position to the new one) and another four input parameters described the movement profile including velocity, acceler-ation, jerk, and snap. These latter parameters described the boundaries which cannot be crossed while executing the movement. The generated trajectory was time-optimal, i.e., the position was reached in the shortest possible time. For simplicity we assumed that the shape of the profiles was symmetric no matter what the direction of movement was.
The direction of movement can be calculated based on the following equation:
where the
variable equals
if the movement direction is positive, or
when it is negative.
While considering the real-time implementation with respect to sampling time of code execu-tion, it is necessary to round up calculated time values:
Fourth order trajectory profiles are shown in
Figure 4.
In the following sections, calculations for the type of trajectory generation for MC_MoveAbsolute() are shown in an algorithmic way.
3.1. Calculation of Time td
The following equations are used for calculation of time
which covers the duration of a single movement section with applied snap boundary (i.e., its constrained value), as in
Figure 4.
Rounding up (4) with respect to the sampling time
Ts:
If the following Equation (7) holds true:
This rounded up with respect to the sampling time (
) yields the following equation:
If the following Equation (12) holds true:
This rounded up with respect to the sampling time (
) yields the following equation:
If the following Equation (17) holds true:
This rounded up with respect to the sampling time (
) yields the following equation:
Time
is derived from Equation (21) as:
The next section shows how to evaluate value of time ().
3.2. Calculation of Time tj
When time (
) is calculated, the very next step is to calculate the value of time (
), while taking into account movement constraints and sampling time rounding of calculated values. The value
means the time of jerk (3rd order derivative of position), as shown in
Figure 4. Derivation of time (
) starts from calculations:
This rounded up with respect to the sampling time (
Ts) yields the following:
If the following Equation (26) holds true:
This rounded up with respect to the sampling time (
) yields the following:
If the following Equation (31) holds true:
This rounded up with respect to the sampling time (
) yields the following:
Time
is derived from Equation (35) as:
The following section considers calculations of acceleration phase time ().
3.3. Calculation of Time ta
When times
and
are calculated, taking into account movement constraints and sam-pling time rounding of calculated values, the next step is to calculate value of time (
). This means the time of acceleration (second order derivative of position), as shown in
Figure 4. The derivation of time (
) starts from the following calculations:
This rounded up with respect to the sampling time (
) yields the following:
If the following Equation (41) holds true:
This rounded up with respect to the sampling time (
) yields the following:
Time
is derived from Equation (45) as:
The following section considers further calculations of the fourth order trajectory profile.
3.4. Final Calculation of Movement Profile Times and Direction
Final calculations (including time of constant velocity movement (
)) start with:
This rounded up with respect to the sampling time (
) yields the following:
Where is calculated in Equation (2).
The column vector in Equation (49) is the final part of the fourth order trajectory profile generation. Now we have all the time values necessary to create the movement profile based on the parameters given by the user. This part of the algorithm is called the trajectory planner. The next part of the algorithm is called the profile generator. It is described in the following section and its purpose is to generate a movement profile out of the times were calculated in previous sections.
4. Generation of Profile
The generation of a movement profile starts with the calculation of switching times
as shown in
Figure 4:
For simplicity, we can assume:
Then Equation (50) can be rewritten in the following form:
where
describes the switching matrix for the fourth order trajectory profile generation. After these calculations, the following holds true as shown in
Figure 5:
Movement starts in time (
), while time moment (
) is the endpoint of the generated move-ment.
Time values from Equation (53) are shown in the following
Figure 5.
4.1. Execution of Trajectory Profile Generation
When the trajectory profile generation is executed (i.e., by the user) and output of the reference position trajectory has started, then the generation of snap profile is based on the following calcula-tions.
The new value of is calculated based on Equation (52) and the resulting Equation (53). The variable is set based on the algorithm shown in the following part of this subsection.
Then:
where
stands for the actual profile generation execution time. Calculations of
values are based on the following conditions/equations:
Which gives the following algorithm:
are calculated iteratively in each time sample of algorithm execution. Then the actual value/shape of derivative of jerk signal is calculated with the following equation:
where the
variable stands for direction of movement. It is a two-valued variable:
calculated with Equations (65)–(68).
When the previous trajectory profile generation is finalized, i.e., time of execution (
) is greater than the sum of
calculated with Equation (54) and some non-zero settling time (
) has passed, then the system is ready for a new trajectory generation:
Determining direction of movement for Equation (63) starts with verifying the condition:
Input
means that the user wishes for execution of the trajectory profile calculation (and profiled movement generation) and information about the readiness of the module for calculations is passed from the input variable
to the variable
. The rising edge of the condition:
enables determination of direction, i.e., calculation of variable
:
Equation (68) is used when we want to switch operation mode of the movement, i.e., motor/servo is mounted in an opposite direction.
4.2. Generation of Start Signal
Generation of the
signal that triggers Equation (56) and results in a new value of the
variable (calculated based on Equation (52) and consequently Equation (53)) is connected with the equation:
The same
variable is used for triggering new profile calculations (Equations (1)–(53)).
4.3. Calculation of Execution Time
Calculation of trajectory profiling execution time (
) is based on the following expressions:
This finishes the algorithm of trajectory profile generation. The next step is to calculate actual values out of the process involving integrating snap signal values. It is shown in the next subsection.
4.4. Generation of Motion Profile Step
To output the motion profile of all the derivatives and the position itself, the following steps need to be executed in a real-time control platform:
These steps finish the trajectory generation procedure.
5. Implementation of Trajectory Generator According to IEC 61131-3
The proposed algorithm was prepared to be transferrable to real-time implementation (e.g., PLC/PAC), which could later be used in industrial control platforms.
The algorithm was divided into the following sections:
Plan Trajectory (
Figure 6) – Equations (1)–(49);
Generate profile (
Figure 6) – Equations (50)–(71); while
Generate Motion (
Figure 6) subsystem calculates Equations (72)–(75).
In
Figure 7, two examples of generated trajectories are shown:
The function blocks code for the 4th order trajectory generator is presented in
Figure 8, with the Simulink model presented in
Figure 6 serving as a base for this conversion. Structured text code generated with a Simulink PLC Coder is about 900 lines long, and the total memory allocated for this function block in PLC is 3 kB. This means that the devised solution is implementable in the majority of PLC/PAC controllers which are IEC-61131-3 [
11,
12] standard compliant.
6. Summary
The article presents, in a step by step manner, the procedure for implementation of a 4th order trajectory generator that mirrors the MC_MoveAbsolute() function. Due to the straightforward nature of Equations (1)–(75), it is easily implementable in any of the available textual or graphical programming languages for real-time control systems.
The implementation of the presented algorithm is possible in control systems adhering to the IEC 61131-3 standard (e.g., PLC), and its source code was generated as a result of applying the fast prototyping paradigms, i.e., it was generated from the Simulink model. As an example, generated profiles are given with different parameters (i.e., boundaries). It is also possible to generate motion profiles of lower orders than fourth—the algorithm itself is scalable and following the procedure presented here will lead to obtaining simpler solutions constrained on third or second derivatives.
The most important contribution of this work is the unique nature of the presented approach, as it allows for practical implementation of this algorithm in commonly used real-time control systems.
The algorithm presented here is fully parametrized. It can be fully integrated by way of interfaces and its functionality, with other motion control features (i.e., collision avoidance or trajectory generation profile correction). As proposed in this paper, the implementation of MC_MoveAbsolute() is parametrized through its inputs (as it can be found in all functions and function blocks in graphical IEC 61131-3 compliant programming languages). Modularity of the approach enables the user to combine a proposed solution with an extension boom elasticity estimation feature (loader or forestry cranes applications) or dynamic collision avoidance (multi-axis serial robotic manipulators).
The function presented here can be implemented without any problems in all PLC/PAC-based control systems. The short sampling time (not more than 200 microseconds) requirement is fulfilled by most available control platforms. In the case of PLC/PACs with higher sampling times proposed, the algorithm can be extended with sampling time correction. In other cases, the integer multiple of sampling time requirement needs to be fulfilled by all times for t0–t15 times in Equation (53).
Author Contributions
Conceptualization, K.P. and M.K.; data curation, M.K.; formal analysis, P.W. and M.K.; funding acquisition, K.P.; investigation, K.P., P.W. and M.K.; methodology, K.P. and M.K.; project administration, K.P.; resources, K.P.; software, K.P.; supervision, K.P.; validation, P.W. and M.K.; visualization, P.W.; writing—original draft, K.P., P.W. and M.K.; writing—review and editing, K.P. and M.K.
Funding
This research was partially funded by: (a) Ministerstwo Nauki i Szkolnictwa Wyższego, grant number R03 042 02, (b) Ministerstwo Nauki i Szkolnictwa Wyższego, grant number N N502 336936 and, (c) Marie Curie 7PR, FP7-PEOPLE-2012-IAPP (Industry-Academia Partnerships and Pathways) grant number 324496.
Conflicts of Interest
The authors declare no conflict of interest.
References
- Biaggiotti, L.; Melchiorri, C. Trajectory Planning for Automatic Machines and Robots; Springer: Berlin/Heidelberg, Germany, 2008; ISBN 978-3-540-85628-3. [Google Scholar]
- Pillay, P.; Krishnan, R. Application Characteristics of Permanent Magnet Synchronous and Brushless dc Motors for Servo Drives. IEEE Trans. Ind. Appl. 1991, 27, 986–996. [Google Scholar] [CrossRef]
- Mariethoz, S.; Domahidi, A.; Morari, M. High-bandwidth explicit model predictive control of electrical drives. IEEE Trans. Ind. Appl. 2012, 48, 1980–1992. [Google Scholar] [CrossRef]
- Gu, J.S.; De Silva, C.W. Development and implementation of a real-time open-architecture control system for industrial robot systems. Eng. Appl. Artif. Intell. 2004, 17, 469–483. [Google Scholar] [CrossRef]
- Moreira, T.G.; Wehrmeister, M.A.; Pereira, C.E.; Pétin, J.F.; Levrat, E. Automatic code generation for embedded systems: From UML specifications to VHDL code. In Proceedings of the 2010 8th IEEE International Conference on Industrial Informatics, Osaka, Japan, 13–16 July 2010; pp. 1085–1090. [Google Scholar] [CrossRef]
- Lambrechts, P.; Boerlage, M.; Steinbuch, M. Trajectory planning and feedforward design for high performance motion systems. In Proceedings of the 2004 American Control Conference, Boston, MA, USA, 30 June–2 July 2004; Volume 5, pp. 4637–4642. [Google Scholar] [CrossRef]
- Boerlage, M.; Steinbuch, M.; Lambrechts, P.; van de Wal, M. Model-based feedfordward for motion systems. In Proceedings of the IEEE Conference on Control Applications, Istanbul, Turkey, 25 June 2003; Volume 2, pp. 1158–1163. [Google Scholar]
- Boerlage, M. MIMO jerk derivative feedforward for motion systems. In Proceedings of the 2006 American Control Conference, Minneapolis, MN, USA, 14–16 June 2006; pp. 3892–3897. [Google Scholar] [CrossRef]
- Lambrechts, P.; Boerlage, M.; Steinbuch, M. Trajectory planning and feedforward design for electromechanical motion systems. Control Eng. Pract. 2005, 135, 145–157. [Google Scholar] [CrossRef]
- Pietrusewicz, K. Multi-degree of freedom robust control of the CNC X-Y table PMSM-based feed-drive module. Arch. Electr. Eng. 2012, 61. [Google Scholar] [CrossRef]
- Programmable Controllers-Part 3: Programming Languages, IEC 61131-3:2013; International Electrotechnical Commission, 2013.
- John, K.H.; Tiegelkamp, M. IEC 61131-3: Programming Industrial Automation Systems: Concepts and Programming Languages, Requirements for Programming Systems, Decision-Making Aids; Springer: Heidelberg, Germany, 2010; Volume 2, ISBN 978-3-642-12014-5. [Google Scholar]
© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).