Arduino-based Artificial Intelligence

At present, the current state of affairs with the use of artificial intelligence (AI) in robotics is not sufficiently covered in the Russian segment of the Internet. The desire to correct this situation prompted the publication of material related to the development of intelligent control systems. The paper considers the historical development of artificial intelligence (fuzzy logic (NL), genetic algorithms (GA), fuzzy neural networks (NNS)) for designing an automatic control system (ACS). Comparison of design methodologies is carried out on the example of a robot based on the Arduino platform.


At present, the development, development and implementation of effective high science-intensive information technologies (IT) (created in various fields of science and technology) are inextricably linked with the need to develop and increase the level of intelligence of the processes and control systems used, which objectively take into account context-dependent physical effects in the laws of control , restrictions and information boundaries that actually exist in specific models of the control object (OS).

In theory and design of control systems, much attention is currently being paid to identifying the role and effective use of robust intelligent control systems (IMS) in the intensive development and qualitative improvement of modern high IT intelligent control of complex physical OS.

The complexity of the description of physical systems, in turn, leads to the need to approximate OS models and apply approximate solutions that do not guarantee the necessary and sufficient conditions for achieving the control goal in unforeseen situations and information risk. Therefore, in theory and control systems, one of the effective approaches to reducing the risk of decision-making (from the incompleteness of the description of the OS model) is the development of robust ICS structures [1].

The evolution of intelligent control systems

The control problems of essentially nonlinear and globally unstable OCs were studied in the presence of various types of stochastic disturbances on the OC. Using the developed system of stochastic modeling, the limiting capabilities of classical self-propelled guns based on the use of an actuator of a self-propelled guns in the form of a traditional PID controller were determined (see Table 1, position 1). As a result of the study, the following fact was established: classical self-propelled guns based on a PID controller with constant gain factors often fail to cope with the control problem in the case of globally unstable and substantially nonlinear op-amps under the influence of non-Gaussian (e.g., Rayleigh) stochastic noise, and also in conditions of time delays in the measurement channels.

This fact is explained by the following circumstances. Classic self-propelled guns are based on the principle of global negative feedback and the control error compensation method. However, in complex opamps (an example with an Arduino robot below), it is not enough to have an optimization result by only one criterion of control quality, such as a minimum of control error. Therefore, in practice, when designing ISU with complex OS, the following problem arises: how to introduce other, additional criteria for the quality of management into the control system?

Table 1. The evolution of ISU

Such criteria include, for example, a minimum of entropy production in the OS, and / or a minimum of entropy production in the control system itself (taking into account heat losses, loss of useful work in the facility and control system), or other more complex, vectorial control quality criteria.

Note. Similar and related issues of constructing a physical theory of control were considered in the works of A.A. Krasovsky, S.V. Emelyanova, Yu.I. Samoilenko, A.G. Butkovsky, L.I. Rozonoer, R. Poplavsky, A.M. Tsirlina A.P. Fradkova and many others other

It is almost impossible to resolve this issue using the design process of a standard PID controller with constant gain factors. The limited possibilities for implementing complex criteria for the quality of control in classic self-propelled guns, especially in the control cases mentioned above, served as a starting point for the development of MIS, based on ideas close to using control strategies used by a human expert in difficult situations.

At the first stage, so-called “soft computing”, based on the theory of fuzzy sets and fuzzy inference, began to be used to model “human-machine” control strategies. So, for example, the structure presented in Table 1-1 is converted into an expert control system Table 1-2 by sequentially building up the component blocks in the classic structure of the ACS (in this case, by introducing a fuzzy output unit) and is an example of the first generation of the ISU (Fig. 1).

Fig. 1. Control system with fuzzy controller

Thus, the first generation of the MIS was a fuzzy expert system (ES). The main role in these ES was played by the quality of the knowledge base (KB), which was determined by the experience and subjective knowledge of a human expert. However, in the case of controlling globally unstable and substantially nonlinear opamps under the influence of complex stochastic noise, it is difficult for even an experienced human expert to find the optimal (from the point of view of control quality) knowledge base. This problem is the bottleneck of all the first (and their subsequent modifications) ISUs. Therefore, the use of ES as a tool for the extraction of knowledge and the formation of a knowledge base (as the basis of the design technology of ISS) did not lead to the expected significant success (although there are many examples of industrial implementation) due to the complexity of the OS and the subjectivity of the information provided by the expert.

From the point of view of design technology, the main problem of introducing the first-generation MIS is their weak adaptability to changes in the OS parameters (caused, for example, by the aging of the OS structure or by a sharp change in the external environment), as well as the low robustness of the obtained control laws. To solve such problems, the second-generation IMS was developed using soft computing technologies combining GA, NNS, and fuzzy controller (HP) in a single chain. This allowed us to exclude the subjective opinion of the expert at the stage of formation of the structure and parameters of the knowledge base of the HP. In turn, the development of ISUs based on soft calculations gave rise to several approaches to the formation of KB structures. Initially, it was planned to form some sufficiently coarsened training signal (OS) from the GA, and to extract the knowledge base by approximating the obtained OS on the NNS.

In the future, the second generation of MIS began to use a new type of feedback called intelligent global feedback.(IGOS), presented in Table 1, (item 4). Its use makes it possible to extract objective knowledge directly from the most dynamic behavior of the OS and the ACS actuator. The IGOS circuit includes a GA to obtain information about the optimal control signal (based on the dynamic and thermodynamic behavior of the op-amp and the PID controller itself) and the NNS, which approximates this optimal control signal using the given structure of the neural network. The main unit in the structure of the ISU of this generation is the optimal control signal modeling system (SMOSU) with the help of a GA and a control quality criterion defined as one of the components of the GA fitness vector-function (Fig. 2).

Fig. 2. Second generation intelligent control system

The main problem to be solved by the fifth generation ISU with IGOS is the possibility of achieving the required level of robustness on a given class of both parametric and external random perturbations of various probabilistic nature (with different probability density functions). Another important problem is the determination of the required relationship between the accuracy of the description (approximation) of the OS and the necessary level of robustness of the entire structure of the ANS. Both of these problems are solved at the second stage of the technology for constructing a knowledge base of ISU using software tools called the Optimizer of Knowledge Bases (OBZ) (Fig. 3).

Fig. 3. The fifth generation intelligent control system. With software tools OBZ

You can get acquainted with the design of ISU in more detail using the examples of designing such systems:
Intelligent control of the manipulator
Method for extracting knowledge from a physically measured signal
Remote configuration of the knowledge

base Let us consider an example of the application of ISAU.

Mathematical Model and Robot

Controlling an object of the “Carriage - Inverted Pendulum” type (Fig. 4) is one of the typical tasks in control theory, because the solution to this problem clearly demonstrates the quality of self-propelled guns. Consider the dynamics of the model in the form of a uniaxial carriage with an inverted pendulum fixed on the axis:

Fig . 4 Model of the “Carriage - Inverted Pendulum” system The

dynamics of this op-amp are described by a system of second-order differential equations derived, taking into account the friction forces and the elasticity of the carriage, from the balance of moments and projections of forces on the horizontal Z axis:

The equations for the rate of entropy production are as follows:

In the z and theta equations, the generalized coordinates; g is the gravity acceleration, ms is the mass of the trolley, m is the inverted pendulum (called the “pole”), l is half the length of the pendulum, k and a1 are the friction coefficients in z and theta, respectively, a2 is the elastic force of the trolley, “xi” external stochastic noise, and u is the control power.

A dynamic system has global dynamic instability; in the absence of a control force, an unlimited increase in the deflection angle occurs, i.e. the pendulum falls. The task of controlling the system is to act (using the control force on the trolley) to hold (stabilize) the pendulum in a vertical position (the angle of deviation of the pendulum axis from vertical to 0) under changing operating conditions.

Fig. 5. The mathematical model implemented in the environment of Matlab Simulink

The model (Fig. 5) includes a PID controller, noise in the control and measurement system, and also a block generating a signal for the controller.
This computer model is used to obtain a training signal and to set up the knowledge base using the OBZ. The main stages of constructing a knowledge base using a general knowledge base are considered in [1,9].

This type of op-amp is typical (benchmark) for testing software tools of robust intelligent control. Examples of such systems are considered in [2 - 8] and are presented in Fig. 6.

Fig. 6. Similar DTs

Consider a device of a similar DT layout. In fig. Figure 7 shows the layout used to test the design technologies of ISAU using SSS. This type of robots is considered in detail here .

Fig. 7. Layout of the system

As a measuring system (Fig. 7, Sensor), the layout uses a board with a combination of sensors — a gyroscope and an accelerometer — 5 DoF (five degrees of freedom) IDG500 / ADXL335. The core and central elements of the system is the Arduino microcontroller based on the ATmega328 processor. The board is equipped with a USB connector for transferring data from the processor to the computer. The USB interface is used during experiments to transmit and receive data (deviation angle and magnitude of the control action), as well as for remote settings, which will be discussed below. The sensors are connected using the analog inputs of the microcontroller.
The basic functions of the layout programs are shown in Fig. 8., in general, they can be written in pseudo-code:
• Measurement
• Filtering
• Management
• Counting time (delay).

Fig. 8. Pseudo-code of the robot operation algorithm

Note that the algorithm of the system layout shown in Fig. 8 is a particular example of a closed-loop self-propelled guns discussed earlier (Table 1-1).


To check the robustness of the controllers, we use two control situations:

1) A typical situation - for which to develop controllers (the situation described in the OS and the mathematical model)

2) Unforeseen situation 1 - additional noise in the system (croup was used in the experiment)

3) Unexpected situation 2 - control delay is increased three times.

Three types of controllers are shown in the video:

1) Classic PID controller
2) Fuzzy controller based on SPS
3) A quantum controller based on new types of calculations using hidden quantum information (a description of a quantum controller and design technology like MIS here and here ).


The structure of this design technology for fuzzy controllers and ISUs should include:

o a multi-criteria GA for searching for optimal control and verification of mathematical models,

o a fuzzy neural network for approximating the optimal control signal found with the GA and extracting the “optimal” KB,

o “ fine tuning of the knowledge base based on GA using informational and entropic criteria.

OBZ allows you to implement the principle of designing the optimal ISU with the maximum level of reliability and controllability of a complex OS in the conditions of uncertainty of the initial information.

The use of KB designed with the help of OBZ in the structure of the IMS expands the field of industrial applications of self-propelled guns to complex dynamic OS.


1. Ulyanov S.V., Litvintseva L.V., Dobrynin V.N., Mishin A.A. Robust Intelligent Control: Soft Computing Technologies, Moscow: VNIIgeosystem, 2011.

2. Grasser, F., D'Arrigo, A., Colombi, S. and Rufer, A. Joe: A mobile inverted pendulum. // IEEE Transaction Electronics. - 2002. - Vol. 49. - No 1. - pp. 107 - 114.

3. Choi D., Oh J.-H. Human-friendly motion control of a wheeled inverted pendulum by reduced-order disturbance observer // IEEE International Conference on Robotics and Automation Pasadena, CA, USA, May 19-23, 2008. - pp. 2521 - 2526.

4. Nawawi SW, Ahmad MN and Osman JHS, Real-time control system for a two-wheeled inverted pendulum mobile - robot, // Advanced Knowledge Application in Practice / I. Fuerstner (Ed). - InTech. - 2010 .-- pp. 299 - 312.

5. Gocmen A. Design of two wheeled electric vehicle. - Master Sci. Thesis. - Atilim University, Temmuz. - 2011.

6. Takeneka T., Hirano M., Izumi H., Kuwabara K., Koyama K., Kobashi Sh. Inverted pendulum mobile vehicle. - Patent US 8,224,891 B2. - Date of Patent. - Jul. 24, 2012.

7. Castro A. Modeling and dynamic analysis of a two-wheeled inverted pendulum. - Master Science Thesis. - Georgia Institute of Technology, Atlanta, USA. - 2012.

8. Nasir A., ​​Ahmad N., Ghazali R., Pakheri N. Performance comparison between fuzzy logic controller (FLC) and PID controller for a highly nonlinear two-wheels balancing robot // 1st International Conference on Informatics and Computational Intelligence - IEEE Computer Society. - 2011. - pp. 176 - 181.

9. Reshetnikov AG, Ulyanov SV, Method for extracting knowledge from a physically measured learning signal: designing the fuzzy controller knowledge bases, “System analysis in science and education”, No. FS77-51141 of 09/14/2012. Issue No 1, 2013

Also popular now: