# Obsessive Control of DC Motors (OCD)

The first patent of an electric motor was filed by the American inventor Thomas Davenport in the early 19th century, in whose time, its primary applications were in printing presses and power machinery tools. Rolling forward a couple of centuries, we have them everywhere from the vibration of mobile phones in our pockets, the ceiling fans in households to robotic manipulators.

These motors, based on their applications, need to be controlled in such a manner to achieve the objective of the task intended. For example, electric vehicles require variable speed control while robotic manipulators often require position control of the actuators which are powered by motors. In this article, I aim to elaborate on how Angle(Position) control could be achieved from a typical DC Motor and a discussion of a few modern methods to improve the performance of the same.

# How do we achieve this?

Almost every Position Control System can be disintegrated down to the constituents of the block diagram shown above. The most vital aspect of the above system is the controller that achieves the position control objective. Therefore, improving the performance of the controller leads to the enhancement of the performance of the position control system as a whole.

## Uncertainties:

In practical systems, disturbances are inevitable and they are present throughout the operation. They are typically modeled as D(x) and D(y) as shown. These disturbances could be both internal as well as external. Internal disturbances include the variation in the resistance of the motor coils due to heating during prolonged operations while external ones include those such as varying atmospheric conditions like pressure, wind, etc. which could adversely affect the operation. The effect of these types of disturbances has to be often neutralized by making the controller robust enough so the required performance criteria could be satisfied.

Also, since the above system is of negative-feedback type, the output measurements need to be reliable so that the controller would be able to perform its task seamlessly. To minimize the errors creeping into the output measurements due to sensor noise, more than one means of measurement could be employed and techniques such as Kalman filters are used to better estimate the present position.

## Primary Aspects:

In modern times, the controllers are often digital, so in the feedback loop, an ADC (Analog/Digital Converter — Typically embedded into sensor modules) is used to convert the real-time analog signals to digital signals. The most important factor that is considered here is the resolution of the ADC module that is incorporated. Ideally, we would like to have a high-resolution ADC so that the loss of data is minimal and the time required to convert the analog to digital values should be made small enough so that we don’t create time lags in our system, which is highly dangerous for the controller operation.

To understand, how a DC Motor is mathematically modeled, you can check this link. The key underlying principles that we need to know about DC motors so that we would be able to develop an intuitive understanding of their operation are that, for a fixed load, the speed of the motor directly depends on the applied voltage. Under this condition, **an** **i ncrease in voltage results increase in speed **and

**for a fixed voltage, the speed of the motor is inversely affected by the load, in this case,**

**an increase**

*in load torque results decrease in speed.*On a very basic level, a very common method that is employed to tackle the controller design is by using a PID based controller. This controller is quite simple, yet disproportionately powerful on the scale of the simplicity by which it could be implemented. Therefore it ends up being a popular choice for several applications. However, it has its shortcomings when it comes to high frequency and very high precision applications.

In the PID block diagram, e(t) simply means the error which is the difference between the reference value and the present value of the state that is being measured. Kp, Ki, and Kd are the control parameters that are typically set based on the performance objectives that are needed to be satisfied. For starters, these parameters can be obtained with methods such as Ziegler Nichols Method of tuning PID parameters.

So far I have been mentioning terms such as “Performance Criteria” and “Performance Objectives”.What do I actually mean by them?

## Performance Criteria and Performance Objectives :

In simple terms, just as how a “good” refrigerator needs to precisely maintain its temperature and humidity within the bounds set by the user, to justify that it is performing well, in case of position control systems, the performance is often defined by criteria such as, is my system reaching its set point within the stipulated time or is my system oscillating too much, or is my system being unresponsive to high-frequency inputs, within the defined conditions of operation.

The individual elements of our system and the algorithms that need to be implemented are chosen and determined solely by the performance objectives that we set. Therefore it is very much essential that we work out these requirements in advance before we start building our position control system.

For example , the data related to the performance of Servo Motors which are typically position control systems are given as “ Average Speed: 60 degrees in 0.20 sec (@ 4.8 V), 60 degrees in 0.16 sec (@ 6.0 V). Torque: At 4.8 V: 8.5 kg-cm and at 6 V: 10 kg-cm”

The above figure shows an attempt to build a very basic Angle Control System from scratch. It runs on a basic PID controller and utilizes a potentiometer as a voltage divider(typically, sensing!) to determine the angle the motor has swept through.

So now, if I set my performance objective to something trivial like, only to demonstrate if it reaches a constant set point in a substantial amount of time, say, in an order of few seconds, then I could very well conclude that my system is performing well. But, in practical applications where set-points keep changing consistently with time and when there is a need to reach those points before the subsequent setpoint commands are received, then this is not a very good system to work with!

So , what are the issues with conventional PID that leads us to consider more advanced controllers for high frequency and high precision applications?

The primary concern for conventional PID is based on robustness and performance issues when subjected to various conditions of operation such as variable loads and high-frequency inputs. As a result of this, the control gains often have to be adjusted to minimize degradation in performance. Often control engineers solve this drawback with methods such as gain scheduling which aids in fine-tuning the control of the motor.

The Fractional PID Controllers!

Fractional Derivatives and Integrals are abstract mathematical concepts that allow us to evaluate the differentials and integrals of fractional orders. Though their math seems to be a bit complex(I would personally recommend you to try solving them by yourself, to understand them better), there are toolboxes available in MATLAB through which they could be implemented.

This is an enhancement to the conventional PID controllers as we get to tweak around with five different parameters(Including the order of the integral and the differential) unlike the usual three in the case of conventional PID controllers. This provides us with a lot of flexibility in improving the performance in a mathematically elegant fashion, by which we could simultaneously satisfy up to five different controller design specifications so that our controller becomes more robust and its range of operation could be improved substantially without much degradation in performance.

The fractional calculus toolbox: https://fomcon.net/fomcon-toolbox/overview/

The flexibility offered by the Fractional PID (F-PID) based controllers when compared to the conventional type can be visualized as shown. The operating points of conventional PID are represented by the four dots, while the F-PID has its operating zone within the entire shaded region!. So, one could imagine the amount of flexibility offered by F-PID. The basic underlying principle of PID remaining the same, this enhancement has been widely used in position control systems(example, Servos) to obtain better performance.

Despite providing us with improvement in performance, the major hurdle that occurs in the implementation is the tuning of the controller gains and the order of differential and the integral to obtain the desired performance, which needs constrained non-linear optimization techniques. For this reason, the MATLAB optimization toolbox has often been used to find the best solution with minimum error. The function used for this purpose is called fmincon(), which finds the constrained minimum of a function of several variables. So, in case you are implementing this controller shortly for any purpose, make sure to check this out.

I hope this article was informative. Cheers!

*This article is published as a part of the **‘Hardware Series’** under **Spider Research and Development Club, NIT Trichy** on a Tronix Thursday!*