# Experiments with Neural Networks in the Identification and Control of a Magnetic Levitation System Using a Low-Cost Platform

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. System Architecture

## 3. System Analysis

#### 3.1. Electromagnetic System Modeling

#### 3.2. Sensors Parameterization

^{3}.

## 4. Classical Controllers

## 5. Neural Control Strategies

#### 5.1. System Identification

#### 5.2. Inverse Neural Controller

#### 5.3. Internal Model Controller

#### 5.4. Model Reference Control

## 6. Conclusions

## Author Contributions

## Funding

## Institutional Review Board Statement

## Informed Consent Statement

## Data Availability Statement

## Acknowledgments

## Conflicts of Interest

## Abbreviations

PID | Proportional-Integral-Derivative |

AI | Artificial Intelligence |

NARMA | Nonlinear Autoregressive Moving Average |

PWM | Pulse Width Modulation |

ADC | Analog-to-Digital Converter |

MOSFET | Metal–Oxide–Semiconductor Field-Effect Transistor |

SRAM | Static Random-Access Memory |

ADU | Analog-to-Digital Units |

ZOH | Zero-Order-Hold |

NARX | Nonlinear AutoRegressive eXogenous |

MSE | Mean Squared Error |

ReLU | Rectified Linear Unit |

ISE | Integral Square Error |

IAE | Integral Absolute Error |

ITAE | Integral Time Absolute Error |

## References

- Åström, K.J.; Hägglund, T. PID Controllers: Theory, Design, and Tuning, 2nd ed.; Instrument Society of America: Research Triangle Park, NC, USA, 1995. [Google Scholar]
- Barbosa, R.S.; Machado, J.A.T.; Ferreira, I.M. Tuning of PID controllers based on Bode’s ideal transfer function. Nonlinear Dyn.
**2004**, 38, 305–321. [Google Scholar] [CrossRef] - Passino, K.M.; Yurkovich, S. Fuzzy Control; Addison-Wesley: Menlo Park, CA, USA, 1998. [Google Scholar]
- Passino, K.M. Biomimicry for Optimization, Control, and Automation; Springer: London, UK, 2005. [Google Scholar]
- Haykin, S. Neural Networks and Learning Machines, 3rd ed.; Pearson: London, UK, 2009. [Google Scholar]
- Jesus, I.; Barbosa, R.S. Genetic Optimization of Fuzzy Fractional PD+I Controllers. ISA Trans.
**2015**, 57, 220–230. [Google Scholar] [CrossRef] - Mishkin, D.; Sergievskiy, N.; Matas, J. Systematic evaluation of convolution neural network advances on the Imagenet. Comput. Vis. Image Underst.
**2017**, 161, 11–19. [Google Scholar] [CrossRef] [Green Version] - Janke, J.; Castelli, M.; Popovic, A. Analysis of the proficiency of fully connected neural networks in the process of classifying digital images. Benchmark of different classification algorithms on high-level image features from convolutional layers. Expert Syst. Appl.
**2019**, 135, 12–38. [Google Scholar] [CrossRef] [Green Version] - Chen, Y.; Shi, Y.; Zhang, B. Optimal Control Via Neural Networks: A Convex Approach. In Proceedings of the ICLR 2019—International Conference on Learning Representations, New Orleans, LA, USA, 6–9 May 2019; pp. 1–21. [Google Scholar]
- Wai, R.J.; Chen, M.W.; Yao, J.X. Observer-based adaptive fuzzy-neural-network control for hybrid maglev transportation system. Neurocomputing
**2016**, 175, 10–24. [Google Scholar] [CrossRef] - Hagan, M.T.; Demuth, H.B. Neural networks for control. Proc. Am. Control Conf.
**1999**, 3, 1642–1656. [Google Scholar] [CrossRef] - Hagan, M.T.; Demuth, H.B.; Jesús, O.D.E. An introduction to the use of neural networks in control systems. Int. J. Robust Nonlinear Control
**2002**, 12, 959–985. [Google Scholar] [CrossRef] - Zhao, S.T.; Gao, X.W. Neural network adaptive state feedback control of a magnetic levitation system. In Proceedings of the 26th Chinese Control and Decision Conference, CCDC 2014, Changsha, China, 31 May–2 June 2014; pp. 1602–1605. [Google Scholar] [CrossRef]
- De Jesús Rubio, J.; Zhang, L.; Lughofe, E.; Cruz, P.; Alsaedi, A.; Hayat, T. Modeling and control with neural networks for a magnetic levitation system. Neurocomputing
**2017**, 227, 113–121. [Google Scholar] [CrossRef] - Jayawant, B. Electromagnetic suspension and levitation. Rep. Prog. Phys.
**1981**, 44, 74. [Google Scholar] [CrossRef] [Green Version] - Ghosh, A.; RakeshKrishnan, T.; Tejaswy, P.; Mandal, A.; Pradhan, J.K.; Ranasingh, S. Design and implementation of a 2-DOF PID compensation for magnetic levitation systems. ISA Trans.
**2014**, 53, 1216–1222. [Google Scholar] [CrossRef] [PubMed] - Hyung-Suk, H.; Dong-Sung, K. Magnetic Levitation—Maglev Technology and Applications; Springer: New York, NY, USA, 2016; Volume 13, p. 256. [Google Scholar] [CrossRef]
- Bächle, T.; Hentzelt, S.; Graichen, K. Nonlinear model predictive control of a magnetic levitation system. Control Eng. Pract.
**2013**, 21, 1250–1258. [Google Scholar] [CrossRef] - Swain, S.K.; Sain, D.; Mishra, S.K.; Ghosh, S. Real time implementation of fractional order PID controllers for a magnetic levitation plant. Int. J. Electron. Commun. (AEÜ)
**2017**, 78, 141–156. [Google Scholar] [CrossRef] - Jafari, A.H.; Hagan, M.T. Application of new training methods for neural model reference control. Eng. Appl. Artif. Intell.
**2018**, 74, 312–321. [Google Scholar] [CrossRef] - Qin, Y.; Peng, H.; Ruan, W.; Wu, J.; Gao, J. A modeling and control approach to magnetic levitation system based on state-dependent ARX model. J. Process Control
**2014**, 24, 93–112. [Google Scholar] [CrossRef] - Beltran-Carbajal, F.; Valderrabano-Gonzalez, A.; Rosas-Caro, J.C. Favela-Contreras, A. Output feedback control of a mechanical system using magnetic levitation. ISA Trans.
**2015**, 57, 352–359. [Google Scholar] [CrossRef] [PubMed] - Chaos, D.; Chacón, J.; Aranda-Escolástico, E.; Dormido, S. Robust switched control of an air levitation system with minimum sensing. ISA Trans.
**2020**, 96, 327–336. [Google Scholar] [CrossRef] [PubMed] - Chacon, J.; Saenz, J.; de la Torre, L.; Diaz, J.M.; Esquembre, F. Design of a Low-Cost Air Levitation System for Teaching Control Engineering. Sensors
**2017**, 17, 2321. [Google Scholar] [CrossRef] [PubMed] [Green Version] - Microsystems, A. A1324-A1325-A1326: Low Noise, Linear Hall Effect Sensor ICs. 2019. Available online: https://www.allegromicro.com/en/Products/Sense/Linear-and-Angular-Position/Linear-Position-Sensor-ICs/A1324-5-6 (accessed on 9 December 2020).
- Microsystems, A. Datasheet ACS711. 2013. Available online: https://static6.arrow.com/aropdfconversion/31faf7d62603aaa2b659e4e2e96e413e49963d95/acs711-datasheet.pdf (accessed on 22 May 2020).
- Simulink Support Package for Arduino Hardware. 2020. Available online: https://www.mathworks.com/matlabcentral/fileexchange/40312-simulink-support-package-for-arduino-hardware (accessed on 31 December 2020).
- Zeltom LLC. Electromagnetic Levitation System; Technical report; Zeltom LLC.: Belleville, IL, USA, 2009. [Google Scholar]
- Microchip. ATmega640/1280/1281/2560/2561 Datasheet. Available online: https://ww1.microchip.com/downloads/en/DeviceDoc/ATmega640-1280-1281-2560-2561-Datasheet-DS40002211A.pdf (accessed on 22 May 2020).
- Myung-Gon Yoon, J.H.M. A Simple Analog Controller for a Magnetic Levitation Kit. Int. J. Eng. Res. Technol. (IJERT)
**2016**, 5, 94–97. [Google Scholar] - Ogata, K. System Dynamics, 4th ed.; Prentice Hall: Upper Saddle River, NJ, USA, 2004; p. 784. [Google Scholar]
- Ogata, K. Modern Control Engineering, 5th ed.; Prentice Hall: Upper Saddle River, NJ, USA, 2010; p. 905. [Google Scholar] [CrossRef]
- William, J.P., III. System Dynamics, 3th ed.; The McGraw-Hill: New York, NY, USA, 2010; p. 913. [Google Scholar]
- Beale, G. Classical Systems and Control Theory-Compensator Design to Improve Steady-State Error Using Root Locus. Available online: https://people-ece.vse.gmu.edu/~gbeale/ece_421/comp_root_ess.pdf (accessed on 25 May 2020).
- Kajan, S. Neural controllers for nonlinear systems in Matlab. In Proceedings of the 16th Annual Conference on Technical Computing, Prague, Czech, 10–13 November 2008; pp. 1–10. [Google Scholar]

**Figure 19.**Comparison of system responses with lead–lag compensator and the inverse model with adaptive block.

**Figure 22.**Comparison of system responses with the inverse model with adaptive block and internal model.

**Figure 23.**Control signal applied by the inverse model with adaptive block and internal model for the sinusoidal reference.

**Figure 25.**Random reference and system response with the inverse model controller with adaptive block.

**Figure 26.**Control signal for the random reference applied by the inverse model controller with adaptive block.

**Figure 29.**Comparison of the system responses with the internal model and reference model controllers.

**Table 1.**Parameters of the system [28].

Component | Value | Units |
---|---|---|

Resistance (R_{e}) | 3.0 | Ω |

Inductance (L_{e}) | 15.0 | mH |

Maximum current | 1.5 | A |

Weight (m) | 3.0 | g |

Diameter | 37.3 | mm |

Thickness | 28.5 | mm |

**Table 2.**Specifications of the ATmega2560 [29].

Parameter | Value | Units |
---|---|---|

Operating Voltage | 5 | V |

Clock Frequency | 16 | MHz |

Flash Memory | 256 | KB |

SRAM | 8 | KB |

EEPROM | 4 | KB |

Constant | Value | Units |
---|---|---|

α | 508 | ADU |

β | 1090 | ADUcm^{3} |

γ | 68.274 | ADU/A |

m | 29.569 | ADU/A |

b | 516 | ADU |

z (cm) | ADC_{i} (ADU) | ADC_{z} (ADU) | i_{calc} (A) | z_{calc} (cm) | z_{optim} (cm) | |z-z_{calc}| (cm) | |z-z_{optim}| (cm) |
---|---|---|---|---|---|---|---|

2.340 | 524 | 615 | 0.267 | 2.233 | 2.236 | 0.107 | 0.104 |

2.670 | 530 | 599 | 0.461 | 2.725 | 2.703 | 0.055 | 0.033 |

2.870 | 533 | 595 | 0.559 | 2.906 | 2.870 | 0.036 | 0.000 |

3.150 | 538 | 594 | 0.721 | 3.115 | 3.055 | 0.035 | 0.095 |

2.340 | 516 | 592 | 0.000 | 2.289 | 2.340 | 0.051 | 0.000 |

3.150 | 516 | 543 | 0.000 | 3.084 | 3.150 | 0.066 | 0.000 |

Total | 0.349 | 0.232 |

Constant | Value | Units |
---|---|---|

α | 507.045 | ADU |

β | 1123.801 | ADUcm^{3} |

γ | 69.474 | ADU/A |

m | 30.084 | ADU/A |

b | 516.343 | ADU |

Network | MSE | Network | MSE |
---|---|---|---|

3d5n | $8.8604\times {10}^{-4}$ | 10d5n | $8.0709\times {10}^{-4}$ |

3d10n | $8.7738\times {10}^{-4}$ | 10d10n | $7.8236\times {10}^{-4}$ |

3d15n | $8.6531\times {10}^{-4}$ | 10d15n | $7.7818\times {10}^{-4}$ |

5d5n | $8.7772\times {10}^{-4}$ | 15d5n | $7.5261\times {10}^{-4}$ |

5d10n | $8.3748\times {10}^{-4}$ | 15d10n | $7.3700\times {10}^{-4}$ |

5d15n | $8.1346\times {10}^{-4}$ | 15d15n | $7.0542\times {10}^{-4}$ |

Network | MSE Step | MSE Sinusoid | MSE Sawtooth | Total |
---|---|---|---|---|

10d5n | $2.5969\times {10}^{-4}$ | $9.0931\times {10}^{-4}$ | $6.6006\times {10}^{-4}$ | $1.8291\times {10}^{-3}$ |

10d10n | $2.5293\times {10}^{-4}$ | $8.7981\times {10}^{-4}$ | $6.6029\times {10}^{-4}$ | $1.7930\times {10}^{-3}$ |

10d15n | $2.5085\times {10}^{-4}$ | $8.8896\times {10}^{-4}$ | $6.6100\times {10}^{-4}$ | $1.8008\times {10}^{-3}$ |

15d5n | $2.4060\times {10}^{-4}$ | $8.7159\times {10}^{-4}$ | $6.9810\times {10}^{-4}$ | $1.8103\times {10}^{-3}$ |

15d10n | $2.4077\times {10}^{-4}$ | $8.9053\times {10}^{-4}$ | $6.9631\times {10}^{-4}$ | $1.8276\times {10}^{-3}$ |

15d15n | $2.4030\times {10}^{-4}$ | $8.9365\times {10}^{-4}$ | $6.9988\times {10}^{-4}$ | $1.8338\times {10}^{-3}$ |

Network | MSE Step | MSE Sinusoid | MSE Sawtooth | Total |
---|---|---|---|---|

1th5s5d | $2.1019\times {10}^{-5}$ | $1.5618\times {10}^{-4}$ | $3.0189\times {10}^{-4}$ | $4.7908\times {10}^{-4}$ |

1th10s5d | $2.0237\times {10}^{-5}$ | $1.5752\times {10}^{-4}$ | $3.0275\times {10}^{-4}$ | $4.8050\times {10}^{-4}$ |

1th15s5d | $2.7159\times {10}^{-5}$ | $1.5577\times {10}^{-4}$ | $3.0127\times {10}^{-4}$ | $4.8420\times {10}^{-4}$ |

1th5s10d | $9.8642\times {10}^{-5}$ | $2.6887\times {10}^{-4}$ | $5.2893\times {10}^{-4}$ | $8.9644\times {10}^{-4}$ |

1th10s10d | $9.8300\times {10}^{-5}$ | $2.7111\times {10}^{-4}$ | $5.2967\times {10}^{-4}$ | $8.9908\times {10}^{-4}$ |

1th15s10d | $1.9305\times {10}^{-2}$ | $2.8199\times {10}^{-4}$ | $2.5666\times {10}^{-2}$ | $4.5253\times {10}^{-2}$ |

**Table 9.**Integral Square Error (ISE), the Integral Absolute Error (IAE), and the Integral Time Absolute Error (ITAE) values for the inverse model controllers.

Step | Sine | Saw | Total | ||
---|---|---|---|---|---|

ISE | Inverse Model | 2.2681 | 1.4103 | 2.2240 | 5.9024 |

Inverse Model + Adaptive Block | 0.1166 | 0.1819 | 0.1884 | 0.4869 | |

IAE | Inverse Model | 9.3312 | 6.8233 | 8.8432 | 24.9977 |

Inverse Model + Adaptive Block | 1.0882 | 2.0457 | 1.6444 | 4.7783 | |

ITAE | Inverse Model | 185.3760 | 139.8848 | 165.4900 | 490.7508 |

Inverse Model + Adaptive Block | 18.2365 | 38.6153 | 29.8916 | 85.7434 |

Step | Sine | Saw | Total | ||
---|---|---|---|---|---|

ISE | lead–lag | 1.6828 | 2.2484 | 2.2968 | 6.228 |

Inverse Model + Adaptive Block | 0.1166 | 0.1819 | 0.1884 | 0.4869 | |

IAE | lead–lag | 8.0435 | 9.0256 | 9.1502 | 26.2193 |

Inverse Model + Adaptive Block | 1.0882 | 2.0457 | 1.6444 | 4.7783 | |

ITAE | lead–lag | 161.1860 | 179.8254 | 184.7707 | 525.7821 |

Inverse Model + Adaptive Block | 18.2365 | 38.6153 | 29.8916 | 85.7434 |

Step | Sine | Saw | Total | ||
---|---|---|---|---|---|

ISE | Inverse Model + Adaptive Block | 0.4531 | 0.3003 | 0.2800 | 1.0334 |

Internal Model | 0.4950 | 0.2193 | 0.2446 | 0.9589 | |

IAE | Inverse Model + Adaptive Block | 3.5459 | 2.6897 | 2.5324 | 8.768 |

Internal Model | 3.9383 | 2.4808 | 2.4100 | 8.8291 | |

ITAE | Inverse Model +Adaptive Block | 72.5602 | 53.4818 | 50.2659 | 176.3079 |

Internal Model | 76.4735 | 49.0349 | 48.2459 | 173.7543 |

Reference | MSE |
---|---|

Training | $2.5257\times {10}^{-3}$ |

Step | $1.0413\times {10}^{-3}$ |

Sawtooth | $1.7806\times {10}^{-3}$ |

Sinusoid | $2.2322\times {10}^{-3}$ |

Step | Sine | Saw | Total | ||
---|---|---|---|---|---|

ISE | Internal Model | 0.4950 | 0.2193 | 0.2446 | 0.9589 |

Model Reference | 0.0786 | 0.1273 | 0.1447 | 0.3506 | |

IAE | Internal Model | 3.9383 | 2.4808 | 2.4100 | 8.8291 |

Model Reference | 0.9126 | 1.6756 | 1.3950 | 3.9832 | |

ITAE | Internal Model | 76.4735 | 49.0349 | 48.2459 | 173.7543 |

Model Reference | 16.8913 | 32.2026 | 27.2355 | 76.3294 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Silva, B.E.; Barbosa, R.S.
Experiments with Neural Networks in the Identification and Control of a Magnetic Levitation System Using a Low-Cost Platform. *Appl. Sci.* **2021**, *11*, 2535.
https://doi.org/10.3390/app11062535

**AMA Style**

Silva BE, Barbosa RS.
Experiments with Neural Networks in the Identification and Control of a Magnetic Levitation System Using a Low-Cost Platform. *Applied Sciences*. 2021; 11(6):2535.
https://doi.org/10.3390/app11062535

**Chicago/Turabian Style**

Silva, Bruno E., and Ramiro S. Barbosa.
2021. "Experiments with Neural Networks in the Identification and Control of a Magnetic Levitation System Using a Low-Cost Platform" *Applied Sciences* 11, no. 6: 2535.
https://doi.org/10.3390/app11062535