The common practice today for achieving Control is by using the Proportional, Integral, and Derivative constants in the PID Controller, which involves an iterative and algorithmic approach to tuning certain parameters to define the system. It is however a sophisticated trial-and-error approach, and doesn't capture all the nonlinearities of the system as it uses just a few parameters. This project suggests a paradigm shift to achieving control, by bringing in a Neural Network based controller having two RNNs. One RNN mimics the electromechanical system, and the other RNN the controller!
To get an idea of what "Control" actually means, let's look at this simple scenario- Lets say you want to heat a burger (vegan of course) to x degrees using a microwave. You are also VERY picky, and need the burger to be exactly x degrees, not x-1 degrees, and not x+1 degrees! The way this could be done is using a feedback mechanism, where the food temperature is checked at regular intervals and based on the error in the current food temperature and required food temperature, a modification is done to the heat setting (increase or decrease). Now the question is- how big a step will you take in increasing/decreasing temperature, what values to start with, how often to check the heat, how to maintain this required temperature once reached, and how to ensure there's smoothness in case there is a change in required temperature- essentially these questions translate to fitting a particular behavior under some constraints.
This is what control is, and the methods being used today- while they may be vary in the exact procedure and efficiency, rely on the same fundamental principle that such an electromechanical system can be controlled and behavior understood using a finite number of variables.
This is well understood as a simplified method that does not capture the complexities of the inherent nonlinearities of higher order control systems.
In the context of controlling and simulating electromechanical systems, we propose an alternative to PID Controllers, employing a sequence of two Recurrent Neural Networks. The key is that using a deep learning approach, we eliminate the need to do any sort of trial and error, however refined it may be. Also, there limitation with having too few parameters to define the system is also removed as the complexity of the RNN can be accordingly increased, and is customizable depending on the electromechanical system to be controlled.
Why consecutive RNNs?
Instead of a controller being restricted to a fixed number of parameters, which then describes the system- we aim to look at the controller as a black-box that builds a correlation between the inputs and the outputs of an electromechanical system, and thus computes the error and the suitable corrections.
The machine taken into consideration throughout this project is one that takes in a time varying sequence of voltages, which is fed using Pulse Width Modulations (PWM) directly proportional to the voltage at that instant. The output of this machine is corresponding time varying sequence of Revolutions Per Minute (RPM). The machine has a device to capture the logged data, such as the PWM and RPM values at an instant. The logged data over a period of time had ~70,000 data points of the form (PWM, RPM). This data set comprised sinusoidal inputs, step inputs, impulse inputs and trapezoidal inputs (PWMs) - with varying slopes and peaks- and their corresponding outputs (RPMs).
The reasoning behind using an RNN, over any other feed-forward neural network is because the inputs and outputs are functions of time and are also dependent on the ordering of events.
Thus, the 70,000 data points is assumed to be a comprehensive list of details of the system, and used this as the training data to model the RNNs. After training the RNN (RNN2 henceforth) to mimic the machine to a high degree of accuracy, it is assumed that this model is a perfect simulation of the machine, and the controller RNN (RNN1 henceforth) is trained using the original dataset, and the data from RNN2. An RNN is trained using another RNN's (pretrained) data!
Architecture
where,
𝑖(𝑡) is Target RPM profile (and input to RNN1)
𝑤𝑖 (𝑡) is the Predicted PWM from RNN1 and the input to machine and RNN2
𝑤0 (𝑡) is the Actual RPM of the machine 𝑣(𝑡) is the predicted RPM of RNN2 (model of the machine)
Here, the RNN2 is a Neural Network replication of the electromechanical system (a motor in this case). So first the RNN2 is trained to mimic the motor behavior to a good degree of accuracy. This has also been tested by varying the PWM inputs and contrasting the output RPM predicted by the RNN and the original RPM values. The loss for this particular network converges in around 50 epochs, and the accuracy reaches values close to 0.88.
Once we have the neural network simulation of the electromechanical system, the controller can be constructed. Simply put, the job of the controller is to ensure the right PWM value is input to the electromechanical system, to finally output a desired RPM value. To find out the right PWM values that needs to be input to the system (RNN2 now, since that is the simulation of the system), we need a mapping from RPMs to PWMs. This essentially works as the inverse of the RNN2!
This particular architecture would ensure that the input to the RNN1 can be the desired output RPM value of the electromechanical system, which is the constraint for the controller. The RNN1, having been trained on the inverse dataset as RNN2 (where inputs and outputs have been switched), will now predict the PWM values corresponding to the input target RPM values.
The predicted PWM values, are in fact the exact values of PWMs that need to be input to the electromechanical system (keeping in mind that voltages are not always exact, and there could be fluctuations based on the inertia of the motor, lag, etc.). Now that we have the exact PWM values that need to be set to motor, we can accurately achieve the desired target output RPM from the motor.
This way, we have effectively built a system that can be told the constraints at the input stage, and the Neural Network controller decides the inputs to the electromechanical system and works as the controller to match the input constraints of reaching the desired outputs.
Can this be looked at as an Autoencoder?
The inverse nature, and the consecutive RNNs may seem a little confusing at first. However, the alternate way to look at this architecture is as though we have independently stumbled upon the discovery of Autoencoder (AE)! An AE has an encoder and decoder part. Here, the first RNN can be looked at as the encoder, which encodes a representation from the RPM feature space into the PWM feature space- which is the encoding! These encodings can be treated as the input to the decoder network, which is RNN2- which translates from the PWM feature space to the RPM feature space.
The difference between a traditional AE and this architecture is that in this architecture, the outputs of RNN1 are not directly used as inputs for RNN2. Only during training of RNN1, is the output of RNN1 sent to a pretrained RNN2 (simulation of motor), to minimize the loss between the RNN2 output (actual RPM) and the input to RNN1 (desired RPM). In an AE however, the outputs of the encoder are directly treated as inputs to the decoder.
Technically speaking, the electromechanical system itself works as the decoder in this case, whereas RNN2 was just a mere representation of the system used to train the controller (RNN1).
Conclusion
It is evident from the graphical representation of the results that the Consecutive Recurrent Neural Network approach a) works, and b) works better than the PID controller as is seen in the above graphs. The plots for the predicted RPM and target RPM fits almost exactly, in comparison to the PID controller where there is significantly more difference between the achieved RPM vs the Target RPM. There a lot of future scope in this domain, as this might just be the start of a new branch of Control Theory. The other conclusions to make from this analysis is that most electromechanical systems, even the nonlinear complex ones, can be modelled using RNNs, LSTMs etc. to a good degree of accuracy. RNN2 in isolation can be used for various testing purposes, thus saving the cost of rent, power, etc. in the factories.
Thanks to Kannan L, Hemamalini J, Shritej C, and Pradeep G for making this project possible!
Comments