Digital Control

AV01

To perform the position control process of the SCARA robot, it is essential to understand the behavior of its actuators, which in this case are a pair of DC motors responsible for the angular movement of its arms. The first step involves obtaining the signal that reflects the actuator's response to a step input. This signal can be sensed in various ways, such as measuring the motor current, determining the angular velocity of its output shaft, or using encoders to know the steps per revolution. In this case, encoders were chosen due to their ease of implementation.

Once the signal was obtained, the electronic connection between the motor and the myRIO data acquisition board, version 2019, was established. For this, a specific interface was used that allowed proper communication between both components.

A sampling time of 10 milliseconds was established for data acquisition, along with an adjustment of the output shaft speed expressed as a percentage. The obtained values exhibited a significantly lower magnitude compared to the duty cycle percentage applied to the input. As a result, the input signal was not visible in the initial graph. However, the data were adjusted so that both the output and input signals began at time zero, facilitating their comparison and analysis.

Subsequently, the process of obtaining the discrete-time transfer function for both motors, designated M1 and M2, was initiated. For each motor, step inputs with duty cycle values of 50%, 75%, and 100% were applied to the PWM signal.

As observed, both motors (M1 and M2) exhibit largely similar behavior in response to the applied input signals. Based on this observation, a linearity analysis was conducted to verify whether the relationship between input and output remains consistent across the entire operating range. In both cases, the results indicated a ratio close to 1, confirming that the motors behave linearly.

To derive the transfer functions from the signals, the two-point method is employed for first-order systems, and the three-point method for second-order systems. The choice of method depends on the graphical behavior observed in the transfer functions compared to the original signal. Once the model that best fits the system's behavior is identified, the corresponding transfer function is determined and subsequently discretized for implementation in the controller.

The responses of the first-order transfer functions are presented below.

The responses of the second-order transfer functions are presented below.

At first glance, it is evident that the signals exhibiting first-order behavior align more closely with the experimental data. Moreover, the transfer functions corresponding to input signals with 75% and 100% duty cycles show the best fit to the original signal. To determine which of these functions best matches the original signal, a comparison of their time responses was conducted, focusing solely on the steady-state value and the settling time. For Motor 1, the signal corresponding to the 75% step input provided the best fit based on its settling time; the same was observed for Motor 2. Based on these results, the transfer functions of the motors were discretized using the 75% duty cycle input signal.

The tuned transfer functions for motors M1 and M2, respectively, are as follows: 

The process continues with the determination of the minimum sampling time using the Nyquist theorem, which indicates that the sampling time must be less than 0.6277 seconds for motor M1 and less than 0.6151 seconds for motor M2. Subsequently, the appropriate sampling time range is determined based on three main criteria: the system's bandwidth, the equivalent time constant (equivalent Tau), and the system response's settling time. These criteria allow for the selection of a sampling time that ensures an accurate representation of the system dynamics without introducing aliasing or loss of relevant information.


The range with the shortest time turns out to be the one based on the settling time for both cases. Based on this range, a sampling time of 0.05 seconds is selected.

The discrete-time transfer function is obtained using the Tustin, Zero-Order Hold (ZOH), and First-Order Hold (FOH) methods.

Graphically, the method that best fits the continuous signal is the Tustin method, even though it starts the system at a value close to 0.01%. Furthermore, when comparing the time responses—considering both the steady-state value and the settling time—the Tustin method shows the greatest similarity to the values of the continuous-time transfer function.

AV02

Starting from the continuous-time transfer function of the Pololu 37D DC motors, along with its discrete-time counterpart, the next step is to determine the appropriate controllers for both speed and position. This is achieved using methods such as the Reaction Curve, Ultimate Gain, and Pole Placement.

Continuous-time and discrete-time transfer function for speed percentage:

Continuous-time and discrete-time transfer function for position in degrees:

Using the Ultimate Gain method, the gain margin and phase margin are utilized to calculate the parameters Ku and Tu, which correspond to the ultimate gain and ultimate period. First, the transfer function for RPM percentage (i.e., the speed transfer function) was evaluated. By applying the margin(Gs) function, the gain margin (GM) and phase margin (PM) were obtained. Then, the parameters Ku and Tu were inserted into the corresponding equations for Kp, ti, and td according to the tuning table, resulting in the following values:

Kp = 0.015, ti = 0.13, td = 0.033.

These PID controller parameters are in continuous time. To convert them to discrete time, they must be entered into the equations for q0, q1, and q2, yielding the following values:

q0 = 0.028, q1 = -0.033, q2 = 0.010.

The discrete-time PID controller parameters are then used in the controller's transfer function, and the corresponding simulation is performed.

The system's response in discrete time shows good dynamics. It behaves like a first-order system, with a steady-state error of zero. However, it has a somewhat delayed settling time compared to the open-loop transfer function, approximately 21 seconds.

Likewise, the controller parameters were obtained using the Reaction Curve method. This process begins with the continuous-time transfer function, focusing primarily on the gain, time constant (tau), and time delay. The corresponding values are: 1.55, 0.31s, and 0.01s. Additionally, it is necessary to calculate the value of θ' (theta prime), which is the sum of the delay and half of the sampling time, resulting in a value of 0.035.

These data are then substituted into the equations for the continuous-time PID controller parameters, yielding the following values:

Kp = 6.857, ti = 0.07, td = 0.0175.

These continuous-time parameters are then converted to discrete-time by applying the corresponding equations, resulting in the following values:

q0 = 11.706, q1 = -9.2082, q2 = 2.4.

Evaluating the controller with the plant in discrete time, the system exhibits the behavior of a stable second-order system with a steady-state error of 0, a significantly reduced settling time compared to the Ultimate Gain controller (0.61s), and an overshoot of 120%. While it shows considerable oscillations, it remains a strong candidate for a controller.

Finally, the Pole Placement method was applied, starting from the design criteria of an overshoot of less than 10% and a settling time under 5 seconds. This resulted in a damping ratio (ζ) of 0.6 and a natural frequency (ωn) of 1.33 rad/s. Using ζ and ωn, the magnitude of Z, as well as its real and imaginary components, were calculated to define the desired characteristic polynomial.

Before this, the characteristic polynomial of the system combined with the PID controller must be obtained. The respective equation is applied for the closed-loop system, by multiplying the controller and the plant transfer function, resulting in the following characteristic polynomial:

                     z^4+(0.1876q0​−1.851)z^3+(0.851+0.04325q0​+

                0.1876q1​)z^2+(0.04325q1​ +0.1876q2​)z+0.04325q2​

It is observed that the characteristic polynomial is of 4th order, meaning that the desired polynomial must also have the same degree. Therefore, two additional poles must be added to the equation. The poles are placed at 0.005 and 0.003, resulting in the following desired polynomial:

                             z^4−1.927z^3+0.9385z^2−0.007414z+1.385×10−5 


By solving the system of equations, the following values are obtained:

q0 = -0.4041, q1 = 0.5592, q2 = 3.2014E-04. These parameters are then entered into the controller transfer function, in order to later analyze its behavior.

The system exhibits stable second-order behavior, but shows a steady-state error, a settling time of 29.5s, and an overshoot of 103%. Compared to the other controllers, this one shows significant oscillation along with steady-state error.

The controllers were also evaluated in the continuous-time system.

Ultimate Gain

As can be observed, the blue curve represents the system output, while the yellow curve is the control signal. The behavior of the system in continuous time closely mirrors that of the discrete-time system.

Reaction Curve

In this particular case, when applying the controller designed using the reaction curve method to the continuous-time system, the system oscillates constantly, becoming unstable; therefore, this controller is not applicable to the system and is discarded as a candidate.

Pole Placement

Although the controller obtained through pole placement shows intense oscillation, it remains completely stable when applied to the continuous-time system, making it a potential candidate for the system.

Subsequently, different analyses of the signal behavior were carried out using performance criteria such as settling time, percentage overshoot, steady-state error, root locus, phase margin, and gain margin. Initially, these criteria are evaluated for the velocity controllers in the discrete-time system, since applying the same controllers to the discrete-time transfer function for position causes the systems to diverge, due to a pole at the origin equal to 1.

By applying the stepinfo() function to each controller with the closed-loop system, the settling time and percentage overshoot values were obtained, as well as the steady-state error. The results are presented in the following table.

A frequency-domain analysis was also carried out for each controller using the margin() function, in addition to evaluating the pole locations to verify system stability.

It is observed that both phase margins are positive; however, the controllers that exhibit instability are those designed using the reaction curve and pole placement methods, mainly due to their low gain margin. Since they fall below 6 dB, these controllers lack robustness against significant gain variations. Additionally, their phase margins are well below 40°, meaning they are prone to destabilization in the presence of disturbances.

Based on these results, the ultimate gain method is the one that best satisfies the frequency-domain criteria.

It is observed that the poles of the Ultimate Gain and Pole Placement methods are marginally stable, as they are very close to a value of 1, i.e., at the stability margin.

Based on the behavior and the performance analysis, the Ultimate Gain method is selected for controller tuning. The tuned parameters are as follows:

q₀ = 0.0875, q₁ = 0.0375, q₂ = 0.

Thus, the final controller is a PI controller, which is applied to the continuous-time system to observe its behavior and control signal. 

The blue curve represents the system output, while the yellow curve corresponds to the control signal. It can be seen that the control signal does not saturate the system. Additionally, it exhibits an overshoot of 23.94% and a settling time of 2.38 seconds, which is very favorable for inclusion as a velocity controller in the SCARA system.

Based on the results obtained with the Ultimate Gain velocity controller, the position controller is tuned using the Reaction Curve Method. The following parameters were obtained:

q₀ = 0.758, q₁ = -1.341, q₂ = 0.600.

The controller is applied to the continuous-time position transfer function, showing the following behavior:

The blue curve represents the system response, while the yellow curve represents the PWM signal to be applied to the motor, expressed as a percentage. As observed, the signal does not saturate the system, but it must respond very quickly to achieve the desired behavior. Additionally, it must handle very low-amplitude oscillations throughout the settling period of the position in degrees.

The system behaves as a second-order system, with an overshoot of 53.67% and a settling time of 7.64 seconds.

Both controllers respond effectively to disturbances, returning to their reference with only a slight oscillation over a short period. A disturbance with an amplitude of 5 was introduced into the system.

Velocity Controller: 

Position Controller:

AV03

First, we need to recalibrate the parameters of our motors to develop an accurate model that matches the motors used in our project. This process involves measuring various motor characteristics, such as encoder frequency, current, and the time required to reach 63% of the steady-state value.

Ultimately, we will obtain the following values along with a dataset of measurable variables—in this case, the encoders' pulses per second.

Using these parameters, we will construct a state-space representation tailored to our experimental data. However, fine-tuning the parameters will be necessary to ensure accurate model performance.

After fine-tuning, we should arrive at a system model that closely fits our real-world measurements.

Before proceeding with the Luenberger observer and Kalman filter implementation, we must first discretize our system using a sampling time of 10 ms. This discrete representation will better align with our acquired experimental data and digital processing requirements. 

Luenberger Observer

In this implementation, we face the constraint of lacking direct current measurements. This limitation necessitates the use of a state observer to reconstruct the full system state from available partial measurements.

The observation matrix C = [0 1] explicitly defines that only angular velocity (the second state variable) is directly measurable, while current (the first state variable) must be estimated. This configuration reflects a common scenario in motor control systems where current sensors may be unavailable or impractical due to cost, space, or noise considerations.

To ensure effective state estimation, we employ pole placement techniques to design the observer dynamics. The process involves:

  1. First determining the system's natural poles through eigenvalue analysis of the state matrix (eig(Ad))

  2. Strategically positioning the observer poles to be twice as fast (by dividing the natural poles by 2)

  3. Calculating the observer gain matrix L using the place() function

The resulting observer poles at 0.1655 and 0.4459 represent a deliberate design choice that:

  • Guarantees faster convergence than the system dynamics

  • Maintains stability in the estimation error dynamics

  • Provides sufficient noise rejection while maintaining responsive estimation

This pole placement ensures the current estimates will converge to their true values rapidly enough to support closed-loop control while remaining robust to measurement noise in the velocity signal.

                                                         L = [-0.0044, 0.6114]

To validate the observer's performance, we implement the estimation structure shown in the figure . This Simulink model demonstrates how the Luenberger observer recursively combines the system model with velocity measurements to reconstruct the unmeasured current while compensating for model uncertainties.

The observer generates a complete state response, successfully reconstructing both current (unmeasured) and angular velocity (measured) as shown in Figure X. This demonstrates the estimator's ability to track all system variables despite having only partial measurements.

Kalman Filter

Due to the absence of direct current measurements, we use a Kalman filter to estimate the motor's full state from partial data—specifically, only the angular velocity (second state) is measured.

The measurement matrix:

                                                                 C= = [0,1]

reflects this, as only angular velocity is directly observed, while current must be inferred.

The Kalman filter combines the motor model with measurement data and noise statistics to provide optimal state estimates. It recursively predicts the state and corrects it using the angular velocity measurement, balancing model uncertainty (process noise Q) and measurement noise R -this will be a constant instead of a matrix, because we could only measure one state- which is estimated from data.

                                                               R = 0.9669


The process noise covariance matrix QQQ required careful manual tuning to avoid model divergence. This tuning reflects the fact that we have more confidence in the measured data than in the purely estimated state, in this case current.

The error covariance matrix P represents the filter's confidence in the state estimates and is updated each iteration to reflect uncertainty, enabling the filter to adaptively weigh the model prediction against new measurements.

The following figures illustrate the performance of the Kalman filter in estimating the motor states. The first plot compares the measured angular velocity against the filter's estimate, demonstrating the filter's ability to closely track the observed output. The second plot shows the estimated motor current, which is not directly measured but reconstructed through the filtering process. 

¡Crea tu página web gratis! Esta página web fue creada con Webnode. Crea tu propia web gratis hoy mismo! Comenzar