Development of a Resolver-to-Digital Converter Based on Second-Order Difference Generalized Predictive Control †

: High-performance motor drives that operate in harsh conditions require an accurate and robust angular position measurement to correctly estimate the speed and reduce the torque ripple produced by angular estimation error. For that reason, a resolver is used in motor drives as a position sensor due to its robustness. A resolver-to-digital converter (RDC) is an observer used to get the angular position from the resolver signals. Most RDCs are based on angle tracking observers (ATOs). On the other hand, generalized predictive control (GPC) has become a powerful tool in developing controllers and observers for industrial applications. However, no GPC-based RDC with zero steady-state error during constant speed operation has been proposed. This paper proposes an RDC based on the second-order difference GPC (SOD-GPC). In SOD-GPC, the second-order difference operator is applied to design a GPC model with two embedded integrators. Thus, the SOD-GPC is used to design a type-II ATO whose steady-state angle estimation error tends to zero during constant speed operation. Simulation and experimental results prove that the proposed RDC system has better performance than other literature approaches.


Introduction
High-performance motor drives require a robust and accurate motor shaft angular position measurement to operate efficiently in harsh conditions [1][2][3]. The angular position is used to estimate the motor shaft speed and perform vector control techniques [4][5][6]. A high error in the angular position estimation produces a high torque ripple that may lead to motor drive malfunctions [6]. Many sensorless techniques were proposed to estimate the angular position without using position sensors [7][8][9][10]. However, most sensorless techniques depend on motor parameters whose values cannot be measured accurately. Hence, sensorless techniques have angular estimation errors [11]. As a result, many applications such as electric vehicles, antennas, and servomechanisms still depend on sensors to guarantee precise angular position information [11][12][13][14][15][16].
Many types of angular position sensors have been developed for industrial applications [12][13][14][15][16]: Hall sensors, magnetoresistive sensors, capacitive sensors, inductive sensors, encoders, resolver, and others. Among these sensors, the resolver is widely applied in harsh environments as it can resist high temperatures, vibrations, shocks, and contamination produced by oil, dust, and mist [17][18][19][20]. The resolver receives a high-frequency excitation voltage and generates two amplitude-modulated voltages that depend on the angular position.
An observer called a resolver-to-digital converter (RDC) estimates the angular position from the resolver outputs. Many RDCs have been proposed in the literature [21][22][23][24][25][26][27][28]. These experimental results shown in Section 4 prove that the proposed ATO has a faster response than other ATOs in the literature, without reducing its robustness against noise. Finally, conclusions are outlined. In this paper, A ∈ n×m denotes that A is an n × m matrix. Figure 1 shows the schematics of the resolver. This sensor consists of an excitation winding and two output windings. The excitation winding is coupled to the motor shaft and receives a sinusoidal excitation voltage v e (t) of several kHz (1-10 kHz) [21][22][23][24][25][26][27][28]: v e (t) = a r cos(ω r t),

Resolver
where a r is the excitation voltage amplitude (in V), ω r = 2π f r , and f r is the excitation voltage frequency (in Hz). Two amplitude-modulated voltages v s (t) and v c (t) are induced in the output windings. Those signals depend on the angular position [24]: v s (t) = k r v e (t)sin(θ(t)), (2) v c (t) = k r v e (t)cos(θ(t)).
where θ(t) is the angular position to be measured, while k r is the transformation ratio. The objective of a resolver-to-digital converter (RDC) is to get the angular position from v e (t), v s (t), and v c (t).

Difference Operation
Let a(k) and b(k) be discrete-time signals (vectors or scalars). The first-order difference operator (∆) and the second-order difference operator (∆ 2 ) are defined as follows [50]: Let M 1 and M 2 be matrices such that M 1 a(k) + M 2 b(k) exists. The aforementioned operators are linear [49,50]: The operator ∆ corresponds to the discrete transfer function C(z) = 1 − z −1 [32].

Conventional GPC
Consider that an n-order SISO (single-input single-output) plant has the following discrete-time space-state model: where u(k) is the plant input, y(k) is the system output, x m (k) ∈ n×1 is the plant state vector, while A m ∈ n×n , B m ∈ n×1 , and C m ∈ 1×n . Consider that the plant does not have an embedded integrator. The control system must have an integrator so that the steady-state error is zero for a step reference. Conventional GPC requires the development of an augmented model with an embedded integrator. This model will be used to predict plant responses. Applying the first-order difference operator (∆) to (8) and (9), based on (6), yields: Note that y(k + 1) = y(k) + ∆y(k + 1) and y(k + 1) = C m ∆x m (k + 1). Based on these results and (10), y(k + 1) is defined in terms of ∆x m (k), ∆u(k), and y(k) [32]: The augmented model defined in (13) is obtained by placing (10) and (12) together in matrix form [32]: where A, B, and C, in (13), are the matrices of the augmented model, while o m ∈ 1×n is a vector composed of zeros. This augmented model allows predicting the plant responses. Consider that the state vector at instant k i , x(k i ), is known. The future control trajectory is defined as: where N c is a variable called the control horizon. On the other hand, the future state variables are: where x(k i + j|k i ) is the predicted state vector at instant k i + j based on x(k i ), while N p is the prediction horizon, with N c ≤ N p . The value of N p defines the length of the prediction window [32]. In GPC, the future state variables are predicted using the control future trajectory and x(k i ) [32]: As y(k) = C m x(k), the plant outputs are predicted based on (16): Putting (17) into a matrix form yields: where Y ∈ N p ×1 is vector with the predicted responses, U ∈ N c ×1 is the vector with the future control actions, while F and φ are defined in (21): Let r(k) be the reference signal of the plant. The objective of GPC is to calculate an optimal vector of U that minimizes the error between the reference and the predicted plant outputs. Let R s ∈ N p ×1 be a vector that contains the references of the predicted responses that composes Y. It is considered that R S is constant inside the prediction window (the set of predictions) [32]. Equation (22) defines the reference vector R s according to [32]: The cost function J, which reflects the control system performance, is defined in [32] as: where I c ∈ N c ×N c is an identity matrix, while r w is a tuning parameter used to control the magnitude of U [32]. Equation (24) shows the value of ∂J ∂U . The optimal solution of (23) makes ∂J ∂U = 0 [32]. By replacing (18) in (24) and after mathematical manipulations, the optimal solution U is defined as indicated in (25) [32]: According to receding horizon approach, only the first element of the optimal control trajectory, i.e., ∆u(k i ),is used to calculate the control law [32]. Thus: Based on (26) and the definition of x(k) in (13), it is possible to prove [32]: The closed-loop GPC system described in [32] can be described as shown in Figure 2, where the z −1 block indicates the discrete delay operator, 1 − z −1 is the discrete transfer function equivalent to the ∆ operator, while 1 1−z −1 corresponds to the discrete-time integrator. The plant input is obtained by integrating ∆u(k i ) in (27).

Second-Order Difference GPC
According to the internal model principle, if the plant has no integrator, then the controller must have two embedded integrators to track ramp references [46]. However, the conventional GPC approach in [32] only has one embedded integrator. Besides, the cost function of the GPC described in (23) considers that the prediction window reference vector (R S ) is constant within the prediction window [32]. However, the reference vector defined in (22) is not constant when the plant reference r(k) is a ramp signal.
Cordero et al. proposed in [49] an adaptation of the GPC algorithm for reference tracking. This approach is based on applying the second-order difference operator in (4) to create an augmented model with two embedded integrators and whose output is the tracking error. For the sake of simplicity, the GPC approach in [49] will be called secondorder difference GPC (SOD-GPC) in this paper.
Applying the second-order difference operator in (8), as this operator is linear, yields: Let e(k) be the tracking error: Hence: Applying the first-order difference operator to (12), (29), and (30) yields [49]: On the other hand, let r(k) = αk + β be the ramp reference signal. Observe that Replacing (31), (33), and (34) in (32) yields: Observe that ∆e(k + 1) = e(k + 1) − e(k). Hence: Replacing (35) in (36) yields: The augmented model proposed defined in (38) is obtained from (28), (35), and (37) [49]: where: Note that the input and the output of (38) are ∆ 2 u(k) and e(k), respectively. In [49], the prediction window is composed by the predicted tracking errors e(k i + 1|k i ), e(k i + 2|k i ), · · · , e(k i + N p |k i ), while the future control trajectory is ∆ 2 u(k i ), ∆ 2 u(k i + 1), · · · , ∆ 2 u(k i + N c − 1). Thus, the vector with the predicted response (Y a ) and the vector with the future control signals (U a ) for the SOD-GPC system proposed in [49] are defined as follows: The proposed augmented model in (38) has a similar structure as the GPC augmented model in (13). Thus, it is possible to apply the method defined in (18) to predict the tracking error (the outputs of the augmented mode) in (38): where F and φ are defined in (21), but replacing the matrices A, B, and C with A 2 , B 2 , and C 2 in (39), respectively. Observe that the desired values of the predicted errors that compose Y a are zero. Therefore, the reference vector is a set of zeros, i.e., R S = 0, which is constant. Replacing Y, U, and R S with Y a , U a , and 0 in (23) and (24) yields [49]: The optimal solution U a for the SOD-GPC makes ∂J ∂U a = 0 in (44). This solution is: Equation (45) defines the optimal control trajectory of the SOD-GPC. According to the receding horizon control principle, only the first element of U a in (45), i.e., ∆ 2 u(k i ), is used to calculate the control law. Thus: The plant input is obtained by integrating ∆ 2 u(k i ) in (46) twice. Figure 3 shows the structure of the SOD-GPC system described in [49]. The dynamics of the control system depends on the tuning of N p , N c , and R w . Let G(z) and G a (z) be the plant's discrete transfer functions and the SOD-GPC augmented model. It was proven in [49]: Equation (48) proves that the augmented model in (38) has two embedded integrators, when the plant has no zeros at z = 1. Hence, the SOD-GPC can asymptotically track the ramp references [49]. Figure 4 shows the structure of the proposed ATO based on the SOD-GPC. Consider that the resolver excitation signal with frequency ω r = 2π f r is generated by the RDC. Thus, the value of this signal is known. Let t = t s k, where t is the discretized time, t s is the sampling time, f s = 1 t s is the sampling frequency, while k denotes the k-th sample. Define ω rs as the normalized resolver excitation frequency: Let θ(k) = θ(kt s ) and θ e (k) = θ e (kt s ) be the actual and estimated angles. Thus, based on (49), the resolver signals in (1)-(3) can be discretized as follows:
Let Z[s(k)] denote the Z-transform of the discrete signal s(k). Let H(z) be the transfer function of the SOD-GPC system (including the integrator G p (z)) shown in Figure 4. H(z) represents the relationship between Z[θ e (k)] and Z[g(k)], i.e., H(z) = Z[θ e (k)] Z[g(k)] . Let h(k) be the impulse response of the SOD-GPC system, i.e., Z[h(k)] = H(z). Hence [51]: where * denotes convolution. As the SOD-GPC is a linear system, it is possible to apply the superposition principle to analyze the ATO response: the estimated angular position (the ATO output) is the summation of the responses produced by e θ (k) and e θ (k)cos(2ω rs k): Through the frequency shifting property, it is possible to prove that the term e θ (k)cos(2ω rs k) is a high-frequency signal, while the ATO acts as a low-pass filter that rejects high-frequency signals [28]. As a result, the effect of the signal e θ (k)cos(2ω rs k) in the angle estimation will be rejected by the ATO: h(k) * [e θ (k)cos(2ω rs k)] ≈ 0.
Replacing (58) in (57) yields: Equation (59) states that the estimated angle mainly depends on the term e θ (k). As a consequence, the ATO can be projected only considering the existence of e θ (k). Thus, the ATO can be approximated as the closed-loop system in Figure 5, where the reference is θ(k), the output is θ e (k), and the SOD-GPC is the controller that reduce the error e θ (k). The plant whose output will be defined by the SOD-GPC algorithm is the integrator represented by G p (z) in Figure 5. An ATO is an observer that estimates the angular position. However, many approaches in the literature model the ATO as a closed-loop system whose objective is to reduce the angle estimation error [24,27,28,45]. In the proposed ATO, the angle estimation error is obtained from the signal g(k). The discrete-time model of the integrator is described through (8) and (9), where A m = 1, B m = t s , C m = 1, and y(k) = x m (k) = θ e (k). The closed-loop error (e(k)) is the angle estimation error, i.e., e(k) = e θ (k). Replacing these terms in (39) yields: The matrices A, B, and C in (60) must be used to obtain the gain matrix K a and the control law according to (21), (46), and (47). The adequate tuning of the parameters N p , N c , and R w is required to define the transient behavior of the ATO.
As G p (z) in Figure 4 is an integrator, then the integral of u(k) is the estimated position θ e (k). Hence, the signal u(k) produced by the SOD-GPC system is the estimated angular speed. However, if the noise power in the resolver signals is high, u(k) should be filtered to get a good speed estimation (the design of that filter is beyond the objectives of this research). As a result, the proposed ATO allows estimating the angular speed.

Effect of Resolver Parameter Variations in the Angle Estimation
Equations (2) and (3) are the ideal representation of the resolver outputs. However, imperfections in the mechanical resolver structure and the signal conditioning circuits introduce distortions to the resolver outputs [52][53][54][55]. The main distortions that affect the angle estimation are: • Amplitude imbalance: amplitude difference between the resolver outputs. • Imperfect quadrature: spatial misalignment between the two resolver phases.
Other distortions, such as DC offset in the envelopes of the resolver outputs and harmonics, have a small effect [52][53][54][55]. The resolver outputs can be modeled, considering the effects of the amplitude imbalance and the imperfect quadrature, as follows: v c (t) = (1 + α)k r v e (t)cos(θ(t)).
where α and β are, respectively, the amount of amplitude imbalance and imperfect quadrature error. These distortions produce low-frequency angle estimation errors [52][53][54][55]. The compensation of the resolver imperfection effects is beyond the objective of this research. However, many calibration techniques have been proposed in the literature to measure and compensate these distortions, which can be applied with the proposed ATO [52][53][54][55].

Simulation Results
A set of simulation tests was performed in MATLAB/Simulink. The sampling rate was set at 50 kHz. The parameters of the resolver sensor are listed in Table 1. The angular position corresponds to the speed curve shown in Figure 6. The proposed ATO was tested considering different values of N p , N c , and R w : Configuration 2: N p = 120, N c = 2, R w = 0.01, • Configuration 3: N p = 102, N c = 10, R w = 0.01.

Parameters Values
Excitation amplitude (a r ) 8 V Excitation frequency ( f r ) 2.5 kHz Transformation ratio (k r ) 0.5 Figure 6. Speed curve used in the tests.
The proposed approach was compared with the ATO described in [56], and with an ATO where the SOD-GPC was replaced by a PI controller (PI-based ATO). Figures 7 and 8 illustrate the ATO in [56] and the PI-based ATO, respectively. The dynamic behavior of the ATO in Figure 7 The Ackermann formula was used to get the matrix K to set the eigenvalues of M. In this paper, those eigenvalues were set as −100 + j100, −100 − j100, and −500. These eigenvalues were selected after many simulations, trying to get a response similar to the proposed ATO. Observe that the complexconjugate eigenvalues are dominant. The application of complex-conjugate eigenvalues to tune an ATO can be found in [28]. On the other hand, the PI regulator of the PI-based ATO in Figure 8 has the discrete transfer function C(z) = 500.52×(z−0.957) The PID tuning tool of MATLAB was used to set the parameters of the PI in order for the PI-based ATO and the proposed ATO to have a similar response. A sampling rate of 50 kHz was used for the discretization process. To avoid algebraic loops in the ATO models, each integrator whose output was the estimated angle was discretized through forward Euler approximation. In contrast, backward Euler approximation was used to implement the other integrators.   Table 2 shows the number of multiplications and sums necessary to implement the SOD-GPC-based ATO, the ATO in [56], and the PI-based ATO, without considering the estimation of the trigonometric functions. The multiplication operation has a longer processing time than the sum operator. Table 2 shows that the SOD-GPC has eight multiplication operators in its structure, two more than the PI-based ATO, which is a low computational cost system due to the modeling's simplicity. On the other hand, the proposed ATO uses less multiplications than the ATO in [56]. The SOD-GPC uses one matrix multiplication, two accumulators ( z z−1 ) (an accumulator uses only one sum), and the estimation of the difference operators (subtractions). As a result, the SOD-GPC has low complexity, and it can be easily implemented.

ATO Sum (+) Multiplication (×)
SOD-GPC-based ATO 9 8 ATO in [56] 6 9 PI-based ATO 3 6 For each ATO configuration, two tests were performed: without adding noise to the resolver outputs and adding noise (zero mean and 0.0002 variance) to the resolver outputs. Figures 9-13 show the angle estimation error for each simulation test.      Table 3 shows the root mean squared error (RMSE) and the error settling time (the time required for the error signal to achieve its steady-state value) for each simulation test. The errors without noise are negligible in all cases. Thus, the main source of angular estimation error is the noise in the resolver outputs. As a result, the value of the RMSE is a measurement of the robustness against noise of the ATO: the lesser the value of RMSE, the better the ATO robustness against noise. According to Table 3, it is possible to see that the ATO in [56] has a higher RMSE and settling time than the proposed approach. As a result, the proposed RDC based on the SOD-GPC has a faster response and greater robustness against noise than the approach in [56]. Besides, the settling time for the proposed ATO is less than the value obtained for the PI-based ATO (both ATOs have similar RMSEs).  [56] 0.61 × 10 −3 0.88 × 10 −3 55.0 × 10 −3 PI-based ATO 0.14 × 10 −3 0.45 × 10 −3 22.3 × 10 −3

Experimental Results
An experimental platform based on hardware-in-the-loop (HIL) was set up to test the proposed ATO. The experimental setup shown in Figure 14 consists of a PC and the FPGA Development and Education Board DE2-115 of ALTERA (based on the FPGA EP4CE115F29C7). An Ethernet cable allowed communication between the FPGA board and the PC. In this paper's HIL testing method, the resolver signals were generated through a Simulink block diagram in the PC. These signals were sent to the FPGA board through the Ethernet cable. The FPGA board received these signals, estimated the angular position through the proposed ATO algorithm, and sent this estimation to the PC block diagram to calculate the angle estimation error. One main advantage of using the HIL method is that the angular position is known in each instant. Thus, the angle estimation error can be calculated with accuracy without requiring high-precision sensors (e.g., 16 bit absolute encoders, which are expensive). Furthermore, different from the simulations, HIL tests allow evaluating the actual effects of implementation problems (e.g., processing delays and the number of bits used in arithmetic operations) in the execution of an algorithm (the ATO in this case) in a digital processor. On the other hand, when a practical resolver is used, an additional angular position sensor with better accuracy (which is difficult to obtain) is required to get the actual angular position.
The proposed ATO was implemented in the FPGA board through a VHDL code, considering the same signal sampling frequency (50 kHz) and the SOD-GPC parameters used in the simulation tests. It was used as a fixed-point data format to perform the arithmetic operations with 32 bits. However, the estimated angular position was represented using 40 bits (30 fractional bits) to better compare the actual and the estimated angle. The emulated resolver signals were the same as those used in the simulation tests.
It was not possible to properly implement the ATO in Figure 7 in the FPGA using 32 bit fixed-point number representation. The main problem was the discretization of the integrators considering a sampling rate of 50 kHz. On the other hand, the SOD-GPC is a discrete-time control system, it being easier to implement in a digital processor (no discretization is needed). As a result, the proposed RDC based on a SOD-GPC-based ATO had a fast response, robustness against noise, and is suitable to implement in digital processors such as FPGAs. However, the PI-based ATO shown in Figure 8, whose structure is simple, was implemented in the FPGA. The same PI regulator used in the simulations, C(z) = 500.52(z−0.957) z−1 , was applied in the experimental tests. As in the simulations, each integrator whose output is the estimated angle was implemented in the FPGA through forward Euler approximation, while backward Euler approximation was used to implement the other integrators. Figures 15-18 show the results for the HIL tests. In the tests without noise, it is possible to see a ripple in the angular position error during constant speed operation (from 0 s to 1 s). This ripple is produced by the limited number of bits used for the arithmetic operations. However, that ripple is negligible (that ripple has an amplitude less than 5 × 10 −5 rad).     Table 4 presents the RMSE and the settling time obtained in each HIL test. These values are similar to those obtained in the simulations. If the value of N c rises, the ATO system will respond faster, but the RMSE will consequently be greater as well. Although the estimation error using the PI had a low RMSE, in the same order as the results obtained, the settling time for the PI-based ATO was almost twice the value obtained for the proposed approach. Besides, the PI-based ATO generated an overshoot (2.8621 × 10 −4 rad) and an undershoot (9.4647 × 10 −5 rad), which did not occur in the proposed ATO.

Conclusions
This paper presents a new angle tracking observer (ATO) based on a second-order difference GPC system (SOD-GPC). The proposed ATO has a steady-state error that tends to zero during constant speed operation, being faster and more robust than other ATOs. Besides, the estimated angular speed can be obtained by filtering the signal u(k) generated by the SOD-GPC algorithm (the design of that filter is beyond the objectives of this research). The GPC approach applied in this work is a discrete-time control system. Hence, the GPC structure is suitable for implementation in a digital processor. Other ATOs, as in [56], are based on the discretization of continuous-time tracking systems. The discretization may reduce the performance of a control system. The proposed ATO's dynamic behavior depends on the values of N p , N c , and R w . Besides, the proposed ATO has a faster response than the PI-based ATO. In future works, heuristic techniques such as genetic algorithms will be used for ATO tuning. Furthermore, experimental tests using a physical resolver and a reference angular position sensor (e.g., a 16 bit absolute encoder) will be performed. However, the tests done in this research indicate that the application of the SOD-GPC algorithm to reduce the angle estimation error allows having a better estimation than using other types of closed-loop regulators (e.g., PI regulators).
Author Contributions: G.G. and R.C. performed the simulation and experimental tests; T.E., G.G. and R.C. collaborated in and supervised the article writing; T.E. did the theoretical analysis of the proposed system. All authors read and agreed to the published version of the manuscript.

Acknowledgments:
The authors wish to thank the Federal University of Mato Grosso do Sul for the support of this research.

Conflicts of Interest:
The authors declare no conflict of interest. Nomenclature a r resolver excitation amplitude (V) f r resolver excitation frequency (Hz) k r transformation ratio N c control horizon N p prediction horizon R w tuning coefficient I identity matrix ∆ first-order difference operator ∆ 2 second-order difference operator ω r resolver excitation frequency (rad/s) λ eigenvalue θ(t) angular position (rad) θ e (t) estimated angular position (rad) ATO angle tracking observer DSP digital signal processor FPGA field programmable gate array RDC resolver-to-digital converter