Embedded Control of the DC Drive System for Education

Taking into account the spread use of the DC motor in robotics, the main objective of the chapter is to promote the knowledge regarding the development of the DC drive system, in didactical manner. Basically, for one motor control the cascaded loop DC drive system is used. Numerical implementation of the DC drive system based on Z-transform discrete method is provided. The electrical drive supposes both control types: the torque and speed. The feedback signals of the control loops are provided by using incremental encoder and of an original load torque estimator. Based on the DC motor dynamics, the appropriate parameters of the speed and torque controllers are provided automatically. On line parameters estimation of the DC motor can assure the performances of the DC drive controllers. The symmetrical and modulus optimum criteria are used. In order to prove the feasibility of the proposed solution, the entire Matlab script of the cascade control of the DC drive is provided. The strategy of the cascaded loop control at constant flux is divided into dynamic regime and into steady state regime. The chapter strategy follows two directions: the first, knowledge developments, the second, the applicative research through the real time implementation.


Introduction
The chapter is addressed to researchers, students, and the users of industrial power converters and electric drives or mechatronics. The chapter contains the mandatory theoretical aspects and methods in order to develop successful DC drive system, being the most used in mechatronics applications. Upon implementing the proposed chapter applications, the readers will have the capability to develop own electric drive system, to bring the idea in practice very fast, and for better understanding of using the drive systems being open to add own contributions in the mechatronics field. The chapter contains the basic concepts and techniques to design, simulate, and implement an electric drive system through a well-structured technical guide. By completing this chapter, the researchers will be familiarized with applying the concepts and techniques to manage adequately an electric drive system, widely found in industry and in mechatronics projects. The chapter strategy follows two directions: first, the theoretical approach (a practical discretization method is provided), and the second, the applicative research (numerical simulations and real-time implementations are provided). The chapter contains a high level of the cross-disciplinarily: electric machines, power electronics converters, Matlab/Simulink, real-time implementation, electrotechnics, measurements, and advanced control techniques.
In Section 2, an overview of the adjustable DC drives is given with the purpose to point out the development trend in the technology. In the next section, the dynamical equations of the DC drive system are provided. Section 4 contains the design of the rotor current and speed controllers. The load torque estimator is described in Section 5. Section 6 comprises the energetically model of the DC drive. Based on the on-line parameters identification procedure [1] the energy balance of the DC drive is performed and the appropriate energetic model is deducted in the Section 6 [2]. The optimal control based on linear quadratic controller is designed in the Section 7. The numerical approach by using Z-transform is provided in Section 8, and the simulation results are provided in Section 9. The real-time implementation of the speed control is included in Section 10. The conclusions of the chapter are placed in Section 11. The entire Matlab script is provided.

Overview of the DC drives
The DC machine can be controlled by using power converters. At low speed, the DC drives are very often used. There are two mainly control techniques: armature voltage control (constant torque region) and field current control (constant power region). The armature voltage control is obtained by maintaining constant field current and the field current control by maintaining the constant armature voltage [3].

The mathematical model of the DC drive system
Under certain hypotheses, the mathematical model of the DC machine could be obtained in state space form.
Supposing a constant value of the DC motor parameters, the DC machine has the compensated winding, the magnetic flux maintained at the constant value, the state space mathematical model of the DC machine becomes as follows [2]: in which J is the reduced inertia moment to the electric motor shaft, T A , the armature time constant, R A , the armature resistance, and the specific constants in which k is the DC motor constant.
The state vector of the DC machine contains two states, xðtÞ ¼ nðtÞ i A ðtÞ ! , the control vector is only the rotor voltage u(t) ¼ u A (t), the perturbation vector is the load torque w(t) ¼ T L (t), and the output of the DC motor is the speed y(t) ¼ n(t). Under these circumstances, the mathematical model of the DC motor becomes Taking into consideration the above mentioned hypothesis, the mathematical model of the DC motor Eq. (1) is linear and invariant.
In order to obtain variable speed, there are two topologies of the power converters for DC motor applications: ac-dc and dc-dc. The mathematical model of the power converter, under certain conditions (continuous conduction, neglecting the voltage drop in conduction mode), represents an ideal power amplifier k D [2].

The cascaded loop control of the DC drive system
The DC drive contains two control loops: the inner-the armature current loop and the outerthe speed loop, Figure 1 [2]. Therefore, the control is in cascaded manner. The current feedback is delivered through an adequate current sensor and the speed feedback is obtained based on numerical derivative of the encoder signals. The desired speed is set as reference signal from a potentiometer. Due to the higher power necessity, the dc-dc four quadrants power converter is added. Therefore, by means of the DC voltage control of the DC machine, the torque and speed are adequately adjusted according to the references. The parameters of the current regulator are obtained by using the modulus criterion, and the parameters of the speed controller are delivered by using the symmetrical optimum criterion (Kessler version).
By taken into account the 10 (V) voltage unified system, the transfer function of the proportional-integral (PI) current controller is expressed as with the following parameters [2]: where: • k D ¼ UN 10 , transfer function of the dc-dc power converter; • k I ¼ 10 , attenuation factor of the current transducer; • T ΣI ¼ T I the sum of the parasitic time constant of the current loop is determined by the time constant of the current transducer.
The transfer function of the PI speed controller has the form: the parameters of the speed controller [2] being deducted from symmetrical optimum criterion: in which: , attenuation factor of the speed transducer;

Load torque estimator
In Figure 2, the operational model of the load torque estimator [4,5] is shown. The calculus of the load torque estimator parameters is based on the imposed performances: desired pulsation ω Ã 0 , and the desired overshoot ξ*, respectively: 6. The energetically model of the DC drive -W m (s) Figure 2. The second-order load torque estimator [2].
By multiplying Eq. (11) with i A (t) term, and Eq. (12) with Ω(t), the power balance of the DC drive can be obtained. In this way, the specific power components are obtained: • The electrical power • Different expressions of the electromagnetic power • The rotor copper power losses • The accumulated power in the rotor inductance • The brush power losses • The mechanical power P u ðtÞ ¼ T L ðtÞ Á ΩðtÞ ð 18Þ • The accumulated power in the rotational masses • The viscous power losses The magnetization frequency of the rotor ferromagnetic core is At the constant flux, the total core losses are or by Taking into consideration the deducted magnetic core losses Eq. (23), the corresponding equivalent torque is as follows or denoted by: The mechanical losses are constant. Therefore, the corresponding torque is as follows: By applying the Laplace transform to Eqs. (11) and (12), the electromechanical model of the DC motor at constant flux is obtained: Based on Eqs. (27) and (28), the energetic operational model of the DC motor is obtained as in Figure 3 [2].

Estimation of the DC drive losses components
By using zero-order hold, the numerical energies are calculated as a sum of the local areas: The losses in the rotor windings at the k-th sampling time are as follows: and the total rotor copper energy over the control interval can be deducted as In the same way, the following energies are calculated: • The input energy of the DC motor • The accumulated energy in the rotor inductance • The accumulated energy in the rotational mass The brush, the mechanical, and the core losses have been ignored.
By knowing the above mentioned energies, the output energy could be calculated: By using the same methodology, the losses of the power converter and the transformer are obtained.

Linear quadratic control
The DC machine operates at maximum efficiency at rated operating point, therefore, in steady state. During transient regime, the copper losses component is the higher loss in the DC machine. In order to reduce the power losses in DC drive, the optimal control block diagram is proposed. The proposed solution combines the advantages of the conventional cascaded control (PI) and optimal control [6,7]. The designed software switch goes in position 1 when the speed error is zero, otherwise goes in position 2 ( Figure 4).

Problem formulation
The problem statement of the optimal control supposes a design of the performance index (functional cost). By minimizing the functional cost, the optimal control solution is obtained without any constraints. The optimal control limits are controlled by introducing the weighting matrices [6,7]. The objectives of the optimal control include the objectives of the conventional drive system (regulation, stability assurance, and robustness to perturbations) and the energy reduction.
The gate drive control is denoted by GDC, the voltage control by u c (Figure 4), the load torque estimator by TL estimator block, the tacho generator by TG, the imposed speed reference and the imposed firing angles. The switch is toggled between position 1 (for conventional control) and fixed position 2 (for optimal control). The conventional control is activated during the steady-state regimes, and the optimal control is activated during transients (starting, stopping, and reversing regimes).
In order to control the DC motor in an optimal manner ( Figure 5), the adopting functional cost is with infinite time horizon: By minimizing the adopted performance function, the optimal control is delivered: in which the symmetrical gain matrix K: is the solution of the algebraic Riccati equation (ARE): 8. Numerical implementation of the DC drive system The continuous signals are converted into digital format by using sampling and hold stages. The reversibility takes place through the digital-to-analog converters (DACs), that is, the digital signals are converted into continuous ones.
The properties of the zero-order hold are to maintain the captured signal at the constant value over the entire sampling period. Therefore, the obtained transfer function is

Mathematical model of the digital current control loop
In Figure 6, the block diagram of the numerical model of the current loop is shown [2].
The switch symbol from Figure 6 represents the sampling and hold process, T being the sampling time.
The transfer between the "s" plane and "Z" one is made by using the Z-transform. By using the transfer function of the zero-order hold, the discrete transfer function could be obtained according to or in the other form Taking into account that z ¼ e sT , the discrete transfer function Eq. (41) becomes Taking into account the residuum theorem of the simple poles, the Z-transform can be calculated as By the other side: By taking into consideration Eqs. (43) and (44), the following recurrent relation is obtained By starting from the current transducer transfer function a similar recurrent equation for the current feedback is obtained: The discrete implementation of the current controller is made by using in the similar manner as for the current filter and using the linearity propriety of the Z-transform On the other hand Taking into consideration the dc-dc power converter ideal amplifier model, the rotor voltage is obtained: By taken into consideration one of the following equations, the output signal of the rotor current loop is obtained: • By neglecting the electromotive voltage • By considering the electromotive voltage

Mathematical model of the digital speed control loop
In Figure 7, the block diagram of the digital speed control loop is shown, in which the equivalent closed loop transfer function of the armature current control is replaced by current loop block.
Taking into consideration the block diagram shown in Figure 7, in the similar manner, the digital implementation of the speed loop is obtained.
Therefore, the imposed filtered speed is The digital equation of the recurrent feedback speed is The speed controller for numerical implementation is as: with the obtained numerical signal of the speed feedback By organizing the numerical equations in the specified order Eqs. (55)-(57), (45), (47), (51)-(53), (58), the digital representation of the DC drive system is obtained.

Numerical simulation results
Taking into consideration the following DC motor of 12 W, 12 V/1 A, 90 r.p.m. at rated load torque of 1.37 Nm, the cascaded control loops are implemented in Matlab by using the deducted numerical equations. The following numerical results have been obtained.
In Figure 8 (left side), the dynamic mechanical characteristic for a starting under different load torque variation (Figure 8, right side) is shown. At the same time, in Figure 9, the implemented load torque estimator result is presented.     Based on the above mentioned digital implementation and taking into consideration that the DC drive is formed by two parts, control and power, the following simulation results are obtained. Therefore, on the control side, there are only analog voltages ([0-10] V unified system) (Figure 9). On the power side, the real signals are shown ( Figure 10). In Figure 9, the following DC dive signals are shown: the filtered speed reference (nfilter), the feedback speed (Nfbck), the output of the speed controller (i.e., the reference of the rotor current, ref. rotor current), and the filtered rotor current reference (Ifilter).
On power side, the real values of the DC drive signals are presented: the rotor voltage (Ua), the rotor current (Ia), the controlled feedback speed as the output signal of the DC drive (n), and the load torque signals (the real, TL and the estimated, TLe). The more accurate estimator performances are presented on the [0.4-0.8]s time interval, in Figure 11.

Real-time speed control
Based on the Arduino platform, the conventional control of the DC drive system is implemented in real time ( Figure 12). It consists of the cascaded control, on-line estimation of the DC motor parameters (Figure 13) based on the recursive least squares method [1], and real-time estimation of the load torque ( Figure 14) [2]. The speed feedback is assured by using an incremental encoder [8]. In order to improve the speed response of the DC drive system, a feedforward additional voltage component has been introduced, as in Figure 15 [9]. In Figures 16-18, the build s-function and the associated Simulink blocks for speed and position calculus from the encoder signals are shown.  The appropriate Matlab functions [1] from Figure 13 are delivered as follows:    By applying the numerical derivative of the position adapted to gear ratio the real speed value is obtained (Figure 19).

Conclusions
This chapter is designed in the didactical manner that allows students and researchers to implement autonomously the mechatronic projects based on the DC drive. Starting from the nameplate data of the DC motor, the provided Matlab software has the ability to calculate the DC motor parameters, the parameters of the current and speed controllers, and includes the numerical implementation of the DC motor cascaded control, energy balance and of the load torque estimator. The price of the proposed DC drive is down due to the fact that the load torque is very expensive and it is replaced by the load torque estimator. By using the Z-transform, the procedure of numerical control is implemented. The implementation of the digital filters and controllers are also provided. Numerical simulations confirm the accuracy of the   proposed DC drive discretization method. Moreover, the real-time control based to Arduino platform has been performed. In order to increase the DC drive performances, the on-line estimator of the DC motor parameters is provided, and the feedforward control voltage component has been added.