Utilization of G-Programming Language for Educational Control Application: Case Study of Magnetic Levitation of Elastic Beam

*Abdallah Amr *Mostafa Eshra *Ayman A. Nada
School of Innovative Design Engineering, Faculty of Engineering, Egypt-Japan University of Science and Technology E-JUST, Alexandria 21934, Egypt. email:[email protected]

Abstract

This paper presents the practical employment of G-Programming tools to demonstrate, design, and implement traditional control algorithms upon magnetic levitation system. The complexity of controlling this type of fast dynamic and sensitive system is vital for highlighting the capabilities of LabVIEW G-programming in control education. PID and Lead-Lag controllers are designed and implemented within the LabVIEW environment, with the ability to tune and optimize the controllers utilizing the Virtual Instruments (VIs) of the control design and simulation toolkit. The paper enables the reader to understand the modelling, testing the control action, and dynamic simulation of the system. Then, deploying the control law in real time. It can be concluded that the G-programming shows a suitable and easy tool for facilitating hands-on, experiential learning and validation in control systems engineering.

Keywords: G-programming, Control demonstration, Magnetic levitation, PID, and Lead-Lag control.

 

1 Introduction

Control systems engineering lies at the heart of various modern technologies, encompassing everything from industrial automation to consumer robotics. Educating young engineers in this vital field necessitates practical tools that bridge the gap between theoretical concepts and real-time applications which is the main topic of this paper. Specifically, the paper presents the ability of LabVIEW’s G-programming language as an efficient, interactive, and friendly-use tool for control education. Several factors contribute to making LabVIEW a good tool for teaching control engineering, as presented in [19, 12, 10]; the real-time Application focus as LabVIEW excels in facilitating real-time control system design and experimentation as that in [5]. Its inherent capabilities in data acquisition, hardware interfacing, and code execution seamlessly integrate theoretical frameworks with understandable outcomes. Educational and Theoretical Alignment in LabVIEW’s graphical programming environment mirrors the flowcharts and block diagrams commonly used in control theory textbooks in the control and design simulation toolkit, allowing for a natural transition from theoretical understanding to practical implementation. LabVIEW offers an open source interface for Arduino integration LINX toolbox, detailed in [14], allowing affordable hardware platforms for their experiments. The process’s cost-effectiveness facilitates wider accessibility and encourages hands-on learning experiences.

The paper also presents an application of classical control techniques, mentioned in [11], including PID and Lead-Lag controllers, for a magnetic levitation system with an elastic beam. These choices are motivated by the Wide Application and Understanding of PID and Lead-Lag controllers as they represent fundamental control strategies widely used in various engineering domains. Their inclusion allows engineers to go through a well-established concepts with proven effectiveness, facilitating a solid foundation in control engineering principles, Moreover, these methods offer satisfactory performance for the chosen system, providing students with a practical demonstration of achievable control outcomes using well-understood techniques.

Although looking towards the future, This paper lays the groundwork for further exploration into advanced control approaches, including magnetic bearing and active magnetic bearing, described in [17] and electromagnetic suspension applications such as MagLev trains, from [18], and other applications listed in [20, 8, 9]. MagLev offers promising solutions within the industrial sector and paves the way for investigating its integration within LabVIEW’s framework for future educational endeavours.

2 Hardware Setup

Achieving operational efficiency in this system with heightened sensitivity necessitates a meticulous selection of components assuring precision in state measurement and accurate execution of desired actuator actions demands thoughtful consideration. The system involves the discerning choice of drivers for actuator control, in conjunction with microcontrollers to facilitate signal transmission and reception, choosing fundamental aspects of the system, mass, length of the cantilever, and the force exerted by the electromagnetic actuator. In this section, the selections made to develop the prototype are discussed.

2.1 Cantilever Beam

The initial aspect of consideration pertains to the selection of the cantilever. An ”Endo Keiki” Stainless Steel Ruler shown in Fig. 1 was chosen for this purpose. The cantilever is strategically equipped with N35𝑁35N35italic_N 35 permanent magnets at the end tip of the beam, to interact with the electromagnet situated above the cantilever, and for sensing purposes, located beneath the cantilever, the sensor measures the position of these magnets, indicating the elevation of the cantilever.

Refer to caption
Figure 1: Cantilever beam fixation

2.2 Electromagnet Actuator

The chosen electromagnet is the ”JF-XP2520252025202520 12V12𝑉12V12 italic_V DC” shown in Fig. 3-E holding force of up to 50N50𝑁50N50 italic_N. However, its availability and cost-effectiveness were more of a cause for choosing the electromagnet. The electromagnet is securely affixed to a stainless steel C-shaped stand, maintaining a consistent 35mm35𝑚𝑚35mm35 italic_m italic_m elevation from the sensor below as shown in Fig. 1. The space between the magnet and the sensor provides room for the cantilever, which can be adjusted in height. The electromagnet’s magnetic field is bidirectional and controlled, and its force can be controlled for either pushing or pulling through a driver.

2.3 Sensor

Distance sensor was quite a challenge, the Linear Hall Magnetic Sensor ”KY-024024024024” shown in Fig. 3-D with its working principle explained in [18] and [13], it detects the elevation of the magnet affixed to the cantilever with a very high sensitivity to small changes ΔVout=1.8mV/GΔsubscript𝑉𝑜𝑢𝑡1.8𝑚𝑉𝐺\Delta V_{out}=1.8mV/Groman_Δ italic_V start_POSTSUBSCRIPT italic_o italic_u italic_t end_POSTSUBSCRIPT = 1.8 italic_m italic_V / italic_G, and after the AD converter the resolution is 0.02V0.02𝑉0.02V0.02 italic_V. For more reliability, a calibration process is done by taking numerous measurements. Subsequently, these measurements were interpolated, [6], and graphically represented as shown in Fig. 2.

Refer to caption
Figure 2: Sensor Calibration Interpolation

2.4 Modules and Microcontroller

The selection of the Arduino Nano shown in Fig. 3-A as our controller is underpinned by its rapid processing capabilities, ensuring minimal delays in managing control and measurement signals with baud rate set to 9600960096009600. Furthermore, its seamless interfacing with LabVIEW makes it optimal for a small prototype.

For the motor driver, The 3Amp 4V-16V DC Motor Driver Cytron MDD3A shown in Fig. 3-B is opted. A low-cost, efficient component to supply power to the electromagnet, coupled with its demonstrated reliability and rapid responsiveness, aligning effectively with the demands of our system.

Lastly, as shown in Fig. 3-C a power supply module providing a stable 12V12𝑉12V12 italic_V was incorporated to ensure the consistent and reliable operation of the entire system.

Refer to caption
Figure 3: System Components: A-Microcontroller Arduino Nano, B-Motor Driver, C-Power Supply, D-Hall Effect Sensor, E-Electromagnet, F-Cantilever Beam

2.5 LabVIEW VIs

Building the virtual instrument VI of LabVIEW is considerably the key to the whole experiment, as illustrated in [4, 3]. Where the laws and theories can be applied to a prototype and compare the results to the model simulation to assess how accurate the modeling of the system was and choose which controller is more optimized. Fig. 4 illustrates the control and design simulation toolkit usage to design the controller on an approximated transfer function of the system and obtain the time response from the simulation loop with the ability to change the design of Lead, Lag, and PID gain parameters.

Refer to caption
Figure 4: LabVIEW Block Diagram of System Simulation
Refer to caption
Figure 5: LabVIEW Block Diagram of Real Time Implementation using Arduino LINX-VIs

However, the LINX toolkit allows us to interface the microcontroller, clarified in [14], either reading the voltage from the sensor or sending a pulse width modulation signal to the motor driver. Moreover, it enables the user to choose which controller to apply on the prototype, define its parameters, and visualize distance and control action, Fig. 5.

3 System Modeling

The system to be modeled -illustrated in Fig. 6- can be described as a cantilever beam with a magnet attached at one end with mass m𝑚mitalic_m, and an electromagnet positioned nearby above, capable of attracting or repelling the magnet when a voltage V(t)𝑉𝑡V(t)italic_V ( italic_t ) is applied to its terminals, and a sensor used to measure the distance y(t)𝑦𝑡y(t)italic_y ( italic_t ) between the magnet and the electromagnet with an offset y0subscript𝑦0y_{0}italic_y start_POSTSUBSCRIPT 0 end_POSTSUBSCRIPT.

Refer to caption
Figure 6: Magnetic Cantilever beam System

In the process of system modeling for the described cantilever beam with a magnet and an electromagnet system, it is essential to establish a mathematical representation that captures the dynamic interactions and responses of the components involved. However, it is essential to make some approximations and assumptions to make the model easier to define and model.

Refer to caption
(a)
Refer to caption
(b)
Figure 7: modeled system as a (a) schematic (b) free body diagram

3.1 Assumptions for Magnetic Levitation Model

In our model, it is assumed that:

  • The magnet and the electromagnet are far apart, no forces are acting between them. Allowing us to focus on the interactions that occur when the electromagnet is activated.

  • An operating point as a reference for our analysis, where the system operates around this specific condition. By focusing on small deflections, aiming to ensure that our analysis remains within the linear range of the system, simplifying the mathematical representation.

3.2 Cantilever Beam

Primarily, the mechanical characteristics of the cantilever beam require representation through principles of structural mechanics. Parameters such as beam length L𝐿Litalic_L, elastic modulus E𝐸Eitalic_E, and geometric shape (moment of inertia I𝐼Iitalic_I) contribute to the determination of stiffness keqsubscript𝑘𝑒𝑞k_{e}qitalic_k start_POSTSUBSCRIPT italic_e end_POSTSUBSCRIPT italic_q, equivalent mass Meqsubscript𝑀𝑒𝑞M_{e}qitalic_M start_POSTSUBSCRIPT italic_e end_POSTSUBSCRIPT italic_q, and dam** coefficient beqsubscript𝑏𝑒𝑞b_{e}qitalic_b start_POSTSUBSCRIPT italic_e end_POSTSUBSCRIPT italic_q. Given parameters for the cantilever beam system; Cantilever length L=150mm𝐿150𝑚𝑚L=150mmitalic_L = 150 italic_m italic_m, Cantilever mass mc=0.02Kgsubscript𝑚𝑐0.02𝐾𝑔m_{c}=0.02Kgitalic_m start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = 0.02 italic_K italic_g, Magnet mass m=0.0075Kg𝑚0.0075𝐾𝑔m=0.0075Kgitalic_m = 0.0075 italic_K italic_g, Cantilever width W=16mm𝑊16𝑚𝑚W=16mmitalic_W = 16 italic_m italic_m, Cantilever thickness t=0.7mm𝑡0.7𝑚𝑚t=0.7mmitalic_t = 0.7 italic_m italic_m, Cantilever modulus of elasticity E=195GPa𝐸195𝐺𝑃𝑎E=195GPaitalic_E = 195 italic_G italic_P italic_a.

Using some calculations, the given system can be converted into a mass-spring-damper system with Meqsubscript𝑀𝑒𝑞M_{eq}italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT, keqsubscript𝑘𝑒𝑞k_{eq}italic_k start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT, beqsubscript𝑏𝑒𝑞b_{eq}italic_b start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT that is easy to formulate its motion model from the free body diagram, the equation of motion of the mass-spring-damper system can be expresses as:

Meqy¨+beqy˙+keqy=f(t)Meqgsubscript𝑀𝑒𝑞¨𝑦subscript𝑏𝑒𝑞˙𝑦subscript𝑘𝑒𝑞𝑦𝑓𝑡subscript𝑀𝑒𝑞𝑔M_{eq}\ddot{y}+b_{eq}\dot{y}+k_{eq}y=f(t)-M_{eq}gitalic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT over¨ start_ARG italic_y end_ARG + italic_b start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT over˙ start_ARG italic_y end_ARG + italic_k start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_y = italic_f ( italic_t ) - italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_g (1)

From equation 1, The equivalent mass, dam** and spring constants are to be calculated from the geometric of the cantilever beam and magnet and using the equations from [7], Appendix 2, table 2.1.4-1, table 2.2.3-2:

Meq=m+0.25mc=0.0123Kgsubscript𝑀𝑒𝑞𝑚0.25subscript𝑚𝑐0.0123𝐾𝑔M_{eq}=m+0.25m_{c}=0.0123Kgitalic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT = italic_m + 0.25 italic_m start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = 0.0123 italic_K italic_g (2)
keq=3EIzzL3=74N/msubscript𝑘𝑒𝑞3𝐸subscript𝐼𝑧𝑧superscript𝐿374𝑁𝑚k_{eq}=\frac{3EI_{zz}}{L^{3}}=74N/mitalic_k start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT = divide start_ARG 3 italic_E italic_I start_POSTSUBSCRIPT italic_z italic_z end_POSTSUBSCRIPT end_ARG start_ARG italic_L start_POSTSUPERSCRIPT 3 end_POSTSUPERSCRIPT end_ARG = 74 italic_N / italic_m (3)

As the dam** coefficient is hard to calculate and depends on the medium and the beam, it is assumed with a small value to make the model work near the realistic response, by intuition:

beq=0.1Ns/msubscript𝑏𝑒𝑞0.1𝑁𝑠𝑚b_{eq}=0.1Ns/mitalic_b start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT = 0.1 italic_N italic_s / italic_m (4)

Now, returning to the motion equation (Eq.1) and transforming it into Laplace domain:

MeqS2Y(s)+beqSY(s)+keqY(s)=F(s)Meqgsubscript𝑀𝑒𝑞superscript𝑆2𝑌𝑠subscript𝑏𝑒𝑞𝑆𝑌𝑠subscript𝑘𝑒𝑞𝑌𝑠𝐹𝑠subscript𝑀𝑒𝑞𝑔\begin{split}M_{eq}S^{2}Y(s)+b_{eq}SY(s)+k_{eq}Y(s)&=F(s)-M_{eq}g\\ \end{split}start_ROW start_CELL italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_S start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT italic_Y ( italic_s ) + italic_b start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_S italic_Y ( italic_s ) + italic_k start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_Y ( italic_s ) end_CELL start_CELL = italic_F ( italic_s ) - italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_g end_CELL end_ROW (5)

By making the substitution F(0)=Meqg𝐹0subscript𝑀𝑒𝑞𝑔F(0)=M_{eq}gitalic_F ( 0 ) = italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT italic_g, so the transfer function will be as follows:

Y(s)F(s)=1/MeqS2+beqMeqS+keqMeq𝑌𝑠𝐹𝑠1subscript𝑀𝑒𝑞superscript𝑆2subscript𝑏𝑒𝑞subscript𝑀𝑒𝑞𝑆subscript𝑘𝑒𝑞subscript𝑀𝑒𝑞\begin{split}\frac{Y(s)}{F(s)}=\frac{1/M_{eq}}{S^{2}+\frac{b_{eq}}{M_{eq}}S+% \frac{k_{eq}}{M_{eq}}}\end{split}start_ROW start_CELL divide start_ARG italic_Y ( italic_s ) end_ARG start_ARG italic_F ( italic_s ) end_ARG = divide start_ARG 1 / italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG start_ARG italic_S start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + divide start_ARG italic_b start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG start_ARG italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG italic_S + divide start_ARG italic_k start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG start_ARG italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG end_ARG end_CELL end_ROW (6)

3.3 Electromagnet

Thirdly, the electromagnet is subjected to an electrical modeling approach. Within the framework of this electrical model, a linear assumption is incorporated to relate the applied voltage to the magnetic force. This assumption is justified by the consideration of a small time constant within the electrical circuit. By assuming linearity, a more straightforward analysis of the system’s behavior is achieved in response to applied voltage variations, linear constant Kv=4.167subscript𝐾𝑣4.167K_{v}=4.167italic_K start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT = 4.167.

V(s)=KvF(s)=4.167F(s)𝑉𝑠subscript𝐾𝑣𝐹𝑠4.167𝐹𝑠V(s)=K_{v}F(s)=4.167F(s)italic_V ( italic_s ) = italic_K start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT italic_F ( italic_s ) = 4.167 italic_F ( italic_s ) (7)

3.4 Sensor

Calibration procedures and empirical data facilitate the establishment of a functional relationship between the sensor’s output voltage and the displacement between the magnet and the electromagnet as illustrated in section 2.3, so the sensor can be considered as a unity feedback for the system.

Finally, from equations 6 and 7, the final transfer function describing the whole system is achieved:

Y(s)V(s)=Kv/MeqS2+beqMeqS+keqMeq=337.5S2+8.1S+5994𝑌𝑠𝑉𝑠subscript𝐾𝑣subscript𝑀𝑒𝑞superscript𝑆2subscript𝑏𝑒𝑞subscript𝑀𝑒𝑞𝑆subscript𝑘𝑒𝑞subscript𝑀𝑒𝑞337.5superscript𝑆28.1𝑆5994\frac{Y(s)}{V(s)}=\frac{K_{v}/M_{eq}}{S^{2}+\frac{b_{eq}}{M_{eq}}S+\frac{k_{eq% }}{M_{eq}}}=\frac{337.5}{S^{2}+8.1S+5994}divide start_ARG italic_Y ( italic_s ) end_ARG start_ARG italic_V ( italic_s ) end_ARG = divide start_ARG italic_K start_POSTSUBSCRIPT italic_v end_POSTSUBSCRIPT / italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG start_ARG italic_S start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + divide start_ARG italic_b start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG start_ARG italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG italic_S + divide start_ARG italic_k start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG start_ARG italic_M start_POSTSUBSCRIPT italic_e italic_q end_POSTSUBSCRIPT end_ARG end_ARG = divide start_ARG 337.5 end_ARG start_ARG italic_S start_POSTSUPERSCRIPT 2 end_POSTSUPERSCRIPT + 8.1 italic_S + 5994 end_ARG (8)

This gives us a root locus of the second order system as shown in Fig. 8, and that makes the system a stable system as all poles are in the negative side of the real axis with poles at s=4.05±77.31j𝑠plus-or-minus4.0577.31𝑗s=-4.05\pm 77.31jitalic_s = - 4.05 ± 77.31 italic_j

Refer to caption
Figure 8: Root Locus - Uncompensated system - using LabVIEW

4 Controller Design

The controller design for the magnetic cantilever beam system discusses the optimization of two important classic control algorithms: A. Proportional-Integral-Derivative (PID) B. the Lead-Lag compensator. Optimizing these controllers will ensure the dynamic behavior of the system and stability of the system, defining the response of the cantilever beam to track reference or reject disturbances.

Refer to caption
Figure 9: Block diagram of system with compensator

4.1 PID Control

The PID controller, a fundamental algorithm in control theory, has been extensively explored in the literature, including studies by [15, 16], [1]. It aims to optimize the magnetic cantilever beam’s response to reject disturbances, particularly those induced by changes in the magnetic field. The formula used is the parallel continuous PID gains given by:

Gc=Kp+Kis+Kdssubscript𝐺𝑐subscript𝐾𝑝subscript𝐾𝑖𝑠subscript𝐾𝑑𝑠\begin{split}G_{c}&=K_{p}+\frac{K_{i}}{s}+K_{d}s\\ \end{split}start_ROW start_CELL italic_G start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT end_CELL start_CELL = italic_K start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT + divide start_ARG italic_K start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT end_ARG start_ARG italic_s end_ARG + italic_K start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT italic_s end_CELL end_ROW (9)

Designing a PID controller is necessary to achieve a smooth response, disturbance rejection, and reference tracking, using the PID tuner algorithm from [2] can ensure a tuned response for the system plant with the block diagram shown in Fig. 9. The tuned response is set to have a small settling time, low overshoot percentage and limited output voltage between 12V:12V:12𝑉12𝑉-12V:12V- 12 italic_V : 12 italic_V and the tuner sets the gains to; Kp=6.55subscript𝐾𝑝6.55K_{p}=6.55italic_K start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT = 6.55, Ki=149.36subscript𝐾𝑖149.36K_{i}=149.36italic_K start_POSTSUBSCRIPT italic_i end_POSTSUBSCRIPT = 149.36, Kd=0.022subscript𝐾𝑑0.022K_{d}=0.022italic_K start_POSTSUBSCRIPT italic_d end_POSTSUBSCRIPT = 0.022. by substituting in PID transfer function equation 9 that gives us the controller transfer function Gcsubscript𝐺𝑐G_{c}italic_G start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT of:

Gc=6.55+149.36s+0.022ssubscript𝐺𝑐6.55149.36𝑠0.022𝑠G_{c}=6.55+\frac{149.36}{s}+0.022sitalic_G start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = 6.55 + divide start_ARG 149.36 end_ARG start_ARG italic_s end_ARG + 0.022 italic_s (10)
Refer to caption
Figure 10: Root Locus of compensated system - PID

Investigating the root locus (Fig. 10) of the compensated system, it’s fair to say that the closed loop poles of the root locus ensure that the system is stable.

4.2 Lead-Lag Control

Concurrently, the Lead-Lag controller introduces a phase lead at specific frequencies and phase lag at others, explained in [11], enhancing the overall responsiveness of the system. Lead-Lag controller transfer function contains a pole and zero for the lead the zero leads the pole to get a specific dynamic behavior and the lag has a pole and zero with a zero close to the origin to minimize the error, the transfer function is as follows:

Gc=Kcs+1τleads+1ατleads+1τlags+1βτlagsubscript𝐺𝑐subscript𝐾𝑐𝑠1subscript𝜏𝑙𝑒𝑎𝑑𝑠1𝛼subscript𝜏𝑙𝑒𝑎𝑑𝑠1subscript𝜏𝑙𝑎𝑔𝑠1𝛽subscript𝜏𝑙𝑎𝑔G_{c}=K_{c}\frac{s+\frac{1}{\tau_{lead}}}{s+\frac{1}{\alpha\tau_{lead}}}\frac{% s+\frac{1}{\tau_{lag}}}{s+\frac{1}{\beta\tau_{lag}}}italic_G start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = italic_K start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT divide start_ARG italic_s + divide start_ARG 1 end_ARG start_ARG italic_τ start_POSTSUBSCRIPT italic_l italic_e italic_a italic_d end_POSTSUBSCRIPT end_ARG end_ARG start_ARG italic_s + divide start_ARG 1 end_ARG start_ARG italic_α italic_τ start_POSTSUBSCRIPT italic_l italic_e italic_a italic_d end_POSTSUBSCRIPT end_ARG end_ARG divide start_ARG italic_s + divide start_ARG 1 end_ARG start_ARG italic_τ start_POSTSUBSCRIPT italic_l italic_a italic_g end_POSTSUBSCRIPT end_ARG end_ARG start_ARG italic_s + divide start_ARG 1 end_ARG start_ARG italic_β italic_τ start_POSTSUBSCRIPT italic_l italic_a italic_g end_POSTSUBSCRIPT end_ARG end_ARG (11)

where 1<α<01𝛼01<\alpha<01 < italic_α < 0 and β>1𝛽1\beta>1italic_β > 1. The Lead-Lag design process is made by defining desired poles of s=200±450j𝑠plus-or-minus200450𝑗s=-200\pm 450jitalic_s = - 200 ± 450 italic_j targeting for an objective of an overshoot Mp=0.25subscript𝑀𝑝0.25M_{p}=0.25italic_M start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT = 0.25 and settling time Ts=10mssubscript𝑇𝑠10𝑚𝑠T_{s}=10msitalic_T start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT = 10 italic_m italic_s designed by the traditional method, [11], to get the presented transfer function for the compensator:

Gc=11s+180s+750s+0.001s+0.0001subscript𝐺𝑐11𝑠180𝑠750𝑠0.001𝑠0.0001G_{c}=11\frac{s+180}{s+750}\frac{s+0.001}{s+0.0001}italic_G start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = 11 divide start_ARG italic_s + 180 end_ARG start_ARG italic_s + 750 end_ARG divide start_ARG italic_s + 0.001 end_ARG start_ARG italic_s + 0.0001 end_ARG (12)

Where ; Kc=11subscript𝐾𝑐11K_{c}=11italic_K start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = 11, τlead=0.00556subscript𝜏𝑙𝑒𝑎𝑑0.00556\tau_{lead}=0.00556italic_τ start_POSTSUBSCRIPT italic_l italic_e italic_a italic_d end_POSTSUBSCRIPT = 0.00556, α=0.24𝛼0.24\alpha=0.24italic_α = 0.24, τlag=1000subscript𝜏𝑙𝑎𝑔1000\tau_{lag}=1000italic_τ start_POSTSUBSCRIPT italic_l italic_a italic_g end_POSTSUBSCRIPT = 1000, β=10𝛽10\beta=10italic_β = 10.

Refer to caption
Figure 11: Root Locus of Compensated system - Lead Lag

The compensated system with the transfer function of equation 12 can be modeled into the root locus (Fig. 11), anticipating the closed loop poles at the gain Kc=11subscript𝐾𝑐11K_{c}=11italic_K start_POSTSUBSCRIPT italic_c end_POSTSUBSCRIPT = 11, which it should gives the targeted overshoot and settling time.

Refer to caption
Figure 12: Simulation response of PID vs Lead-Lag controllers

In Fig. 12, the red solid line shows the PID controller response to the step input (blue solid line), and the green solid line is the Lead-Lag compensator response to the same step input. Also, from the LabVIEW time parameter calculator, the PID response is Ts=0.776578ssubscript𝑇𝑠0.776578𝑠T_{s}=0.776578sitalic_T start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT = 0.776578 italic_s, Mp=0.116312%subscript𝑀𝑝percent0.116312M_{p}=0.116312\%italic_M start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT = 0.116312 %, ess=0subscript𝑒𝑠𝑠0e_{ss}=0italic_e start_POSTSUBSCRIPT italic_s italic_s end_POSTSUBSCRIPT = 0, the Lead-Lag response is Tssubscript𝑇𝑠T_{s}italic_T start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT = 0.025s0.025𝑠0.025s0.025 italic_s, Mpsubscript𝑀𝑝M_{p}italic_M start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT = 37.57637.57637.57637.576%, esssubscript𝑒𝑠𝑠e_{ss}italic_e start_POSTSUBSCRIPT italic_s italic_s end_POSTSUBSCRIPT = 0.00250.00250.00250.0025.
PID behavior can be explained by the fact that the closed loop poles from the root locus shown in Fig. 10 define the system as a third-order response with a dominant first-order response and some oscillations to reach a steady state error. On the other hand, it’s noted that the Lead-Lag response is as predicted before with a little high overshoot due to the sensitivity of the system, however, showing a small settling time compared to the PID response.

5 Results

5.1 Solver Optimization

To apply dynamic system modeling, solving differential equations is necessary to get the time response of the simulation model and the real-time to apply the compensator function. LabVIEW Control Design and Simulation toolkit offers ordinary differential equation (ODE) solvers for simulation. In specific systems, such as ours, the Euler solver’s computation time induces continuous oscillations, and fluctuating actions.
To tackle this problem, modifications were introduced to enhance the solver’s response by applying Runge-Kutta 23232323 solver with variable step time (range 10ms:100ms:10𝑚𝑠100𝑚𝑠10ms:100ms10 italic_m italic_s : 100 italic_m italic_s, tolerance 0.10.10.10.1, sampling time 0.01s0.01𝑠0.01s0.01 italic_s), which notably improved the system’s response, although the solver with smaller step time will take too long to compute the output losing the real-time ability of the system.

Refer to caption
Figure 13: Real Time Response of PID vs Lead-Lag Controllers
Refer to caption
Figure 14: Action amplitude of PID vs Lead-Lag Controller

5.2 Comparison

Table 1: PID data
Simulation Real
Tssubscript𝑇𝑠T_{s}italic_T start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT 0.776578s0.776578𝑠0.776578s0.776578 italic_s 0.6s0.6𝑠0.6s0.6 italic_s
Mpsubscript𝑀𝑝M_{p}italic_M start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT 0.1163120.1163120.1163120.116312% 00%
esssubscript𝑒𝑠𝑠e_{ss}italic_e start_POSTSUBSCRIPT italic_s italic_s end_POSTSUBSCRIPT 00 00
Table 2: Lead-Lag data
Simulation Real
Tssubscript𝑇𝑠T_{s}italic_T start_POSTSUBSCRIPT italic_s end_POSTSUBSCRIPT 0.025s0.025𝑠0.025s0.025 italic_s 0.15s0.15𝑠0.15s0.15 italic_s
Mpsubscript𝑀𝑝M_{p}italic_M start_POSTSUBSCRIPT italic_p end_POSTSUBSCRIPT 37.57637.57637.57637.576% 90909090%
esssubscript𝑒𝑠𝑠e_{ss}italic_e start_POSTSUBSCRIPT italic_s italic_s end_POSTSUBSCRIPT 0.00250.00250.00250.0025 00

Lead-Lag controller time response from Fig. 13 (green solid line) and table. 2 from LabVIEW time parameter calculator, indicates a similar behavior to that of the simulation in Fig. 12, with a settling time slightly longer than the simulation settling time, as indicated in table.2. Even so, the overshoot exceeded the simulation overshoot by far arguably because of the sensitive structure that is stimulated by small forces. Steady-state error remained nearly zero verifying the Lag compensator effect to the system.
In contrast, PID controller proves advantageous by eliminating overshoot entirely, along with a settling time of 0.6 seconds showing high similarity to the simulation results, Fig. 12 and Table. 1. Compared to Lead-Lag compensator, Lead-Lag has a shorter settling time of 0.15 seconds, but with aggressive overshoot, and it’s fair to say that both have approximately 0 steady state error.
Also, control action is an aspect that must be taken into consideration due to the limitation of voltage supply to the electromagnet. In the comparison of control action amplitude Fig. 14, PID shows a smooth gradual response with small fluctuations due to the discrete time step of the solver, section 5.1. Where Lead-Lag is seen to have a high amplitude in the beginning causing the high overshoot response, but stabilizes and reaches the same amplitude as PID.

6 Conclusion

The paper work reveals that the LabVIEW G-programming language provides a user-friendly interface that positively contributes to the understanding of control theory, and witnessing the effect of optimizing and tuning parameters on the time response of the system. It is experiencing the influence of selecting ODE solvers, the step size, and the required accuracy with respect to the real-time constraints. Moreover, it could verify the system modeling, approximations, simulation, and real-time implementation. It also facilitates the interface with low-cost microcontrollers through serial data transfer. In conclusion, LabVIEW enables the engineer to maximize system performance with an economical and low-priced control solution. The paper presents the dynamic model of magnetic levitation system, the frequency and time analysis and control system design by utilizing the PID and Lead-Lag controllers. The real-time implementation through hardware-in-loop control system shows satisfactory results with respect to the desired performance.

References

  • [1] Yasser M Alsayed, AA Abouelsoud, and Ahmed MR FathEl-Bab. Fuzzy logic-based pi controller design and implementation of shape memory alloy actuator. International Journal of Automation and Control, 12(3):427–448, 2018.
  • [2] Karl Johan Åström and Tore Hägglund. Advanced PID control. ISA-The Instrumentation, Systems and Automation Society, 2006.
  • [3] Robert H. Bishop. Modern Control Systems with LabVIEW. National Technology and Science Press, New York, 2012.
  • [4] Robert H. Bishop. Learning with Labview. Pearson Education, Inc., Upper Saddle River, New Jersey,NJ 07458, 2015.
  • [5] Safae Bourhnane, Mohamed Riduan Abid, Rachid Lghoul, Khalid Zine-Dine, Najib Elkamoun, Mohamed Bakhouya, and Driss Benhaddou. Real-time control of smart grids using ni compactrio. In 2019 International Conference on Wireless Technologies, Embedded and Intelligent Systems (WITS), pages 1–6. IEEE, 2019.
  • [6] Richard L Burden. Numerical analysis. Brooks/Cole Cengage Learning, 2011.
  • [7] Ira Cochin. Analysis and design of dynamic systems. Harper & Row, 1997.
  • [8] Hyung-Suk Han and Dong-Sung Kim. Magnetic levitation. Springer Tracts on Transportation and Traffic. Springer Netherlands, 247, 2016.
  • [9] Guancheng Liu, Yonghua Lu, Jiajun Xu, Zhanxiang Cui, and Haibo Yang. Magnetic levitation actuation and motion control system with active levitation mode based on force imbalance. Applied Sciences, 13(2), 2023.
  • [10] Ayman A Nada and Mona A Bayoumi. Development of embedded fuzzy control using reconfigurable fpga technology. Automatika, 65(2):609–626, 2024.
  • [11] Katsuhiko Ogata. Modern control engineering, Fifth Edition. Pearson, 2010.
  • [12] Pedro Ponce-Cruz, Arturo Molina, and Brian MacCleery. Fuzzy Logic Type 1 and Type 2 Based on LabVIEW FPGA, volume 334. Springer International Publishing, 2016.
  • [13] Edward Ramsden. Hall-effect sensors: theory and application. Elsevier, 2011.
  • [14] Marco Schwartz and Oliver Manickum. Programming Arduino with LabVIEW. Packt Publishing Ltd, 2015.
  • [15] EM Shaban and Ayman A Nada. Proportional integral derivative versus proportional integral plus control applied to mobile robotic system. Journal of American Science, 9(12):583–91, 2013.
  • [16] EM Shaban and Ayman A Nada. The development of proportional-integral-plus control using field programmable gate array technology applied to mechatronics system. American Journal of Research Communication, 2:14, 2014.
  • [17] Beale Shafai, S Beale, P LaRocca, and E Cusson. Magnetic bearing control systems and adaptive forced balancing. IEEE Control Systems Magazine, 14(2):4–13, 1994.
  • [18] Anna Sibilska-Mroziewicz, Sławomir Czubaj, Edyta Ładyżyńska-Kozdraś, and Krzysztof Sibilski. The use of hall effect sensors in magnetic levitation systems. Applied Mechanics and Materials, 817:271–278, 2016.
  • [19] Guoqiang Wang and Hugo A. Andrade. Labview: A graphical system design environment for adaptive hardware/software systems. pages 82–82. IEEE, 6 2010.
  • [20] Hamid Yaghoubi et al. The most important maglev applications. Journal of Engineering, 2013, 2013.