Journal of Fuzzy Systems and Control, Vol. 2, No 3, 2024

An Application of STM32F4-Embedded ANFIS-Fuzzy Controller for Tower Crane

Ngoc-Truong-Son Nguyen 1, Quang-Hai Dang 2, Dang-Khang Nguyen 3, Duc-Quan Lam 4, Vo-Hoai-Nam Nguyen 5, 

Nguyen-Phap-Tri Le 6, Nguyen-Khang Tran 7, Van-The-Hieu Bui 8, Thai-Hoa Nguyen 9, Thi-Hong-Lam Le 10,*

1, 2, 3, 4, 5, 6, 10 Faculty of Electrical and Electronics Engineering, Ho Chi Minh City University of Technology and Education (HCMUTE), Vietnam

7, 8, 9 Faculty of International Education, Ho Chi Minh City University of Technology and Education (HCMUTE), Vietnam

Email: 1 19151024@student.hcmute.edu.vn, 2 21145629@student.hcmute.edu.vn, 3 21161324@student.hcmute.edu.vn,  

4 21161351@student.hcmute.edu.vn, 5 21145212@student.hcmute.edu.vn, 6 20151070@student.hcmute.edu.vn,

7 19161002@student.hcmute.edu.vn, 8 19161055@student.hcmute.edu.vn, 9 20151276@student.hcmute.edu.vn,

10 lamlth@hcmute.edu.vn

*Corresponding Author

Abstract—In this paper, we examine tower crane – a MIMO under-actuated system- which is popular in both academia and industry. From a successful PID controller for this model, we design a fuzzy controller that is generated by the ANFIS toolbox from MATLAB. The proposed controller is shown to be viable based on both the simulation and experimental results obtained. In experiments, the angle of load vibrates a maximum of 10 degrees around the set angle and the settling error is a maximum of 1 degree. Also, the settling time of the trolley is a maximum of 12 sec. These results are acceptable. This control method controls positions and decreases the fluctuation of this model. In the hardware platform, STM32F4 Discovery is used as a control board, and it is well-embedded by fuzzy blocks to prove its ability in future intelligent control.

Keywords—Tower Crane; STM32F4; Fuzzy Control; ANFIS; MIMO Under-Actuated

  1. Introduction

In control engineering, standard models, such as pendulous [1] and ball and beam [2], are used to examine control algorithms in laboratories. However, the requirement of researching models which are popular in both academia and industry exists. Therefore, kinds of models, such as cranes [3], anti-vibration model to protect buildings from earthquake [4] are more interested due to their uses in real life. Tower crane is a popular model in construction and transferring goods [5]. It is also a standard model in the control laboratory by the company INTECO. With this standard model, LQR control [6], fuzzy control [7] and sliding mode control [8] are tested well on this experimental model. However, the price of this educational model is high. Thence, self-made real-time models are developed in [9]. In that model, a fuzzy controller is developed from structure of 81-rule fuzzy blocks for two separated SIMO systems. In that research, the control board is DSP TMS320F28335 which is also expensive. Its ability to widen the hardware platform for students is low.

Arduino is a much cheaper and more popular control board than DSP. It is supported by a large community [10]. However, only linear control algorithms, such as PID and LQR can be embedded well to control simple models, such as a ball in the tube [11] or heating oven [12]. If being used to control complex models, such as tower cranes, it cannot be used due to its low-velocity operation. Arduino is not suitable for intelligent control for MIMO under-actuated models, such as tower cranes.

STM32F4 can be MATLAB-embedded to control SIMO systems as a high-order inverted pendulum system in nonlinear and intelligent control [13]. Also, for MIMO under-actuated, in [14], PID control structure is applied well for tower crane in both simulation and experiment. In the experiment, those authors embedded successfully MATLAB/Simulink blocks which imitate the PID structure to control positions and anti-fluctuation well. The control board in that research is still STM32F4, which is much cheaper than DSP TMS320F28335. Actually, to control a black-box or grey-box model, such as a reality complex tower crane, intelligent control is a solution. Therefore, a survey of using fuzzy controllers in embedding for STM32F4 is necessary to prove the ability to develop hybrid controllers and intelligent controllers for this model.

In this study, depending on a former PID control structure in [14], we use the ANFIS toolbox to generate a fuzzy controller. This intelligent controller will be examined in simulation before transferring to an embedded program for the real-time model. We prove that embedded intelligent blocks can be applied well to an experimental model.  

  1. mathematical model

The dynamic equations of a complex real model, such as the crane in the experiment of this paper can be obtained through the identification method as in [15] or using neural networks as in [16] to make simulation close to the experiment. However, the structure of the resistor sensors, which will be presented in the experiment of this paper, makes uncertain noise in signals. Thence, collected data may include noise to make the dynamic equations not exact. Moreover, in this paper, we need to examine the ability of a fuzzy controller on the crane. Thence, if the fuzzy method is good in simulation, it is possible in a real model. The total exactness of the simulation model to a real model can be accepted. A popular and simple mathematical model in [17] of tower cranes can be obtained. In that research, only simulation is shown. However, the dynamic equations are shown adequately in that research. The system parameters, variables, and their values can be referred to in Table 1 and Table 2. The mathematical model can be seen in Fig. 1 and Fig. 2 for considering variables.  From [17], dynamic equations of the tower crane are shown in (1)-(4).

(1)

(2)

(3)

(4)

where

  1. System variables

Symbol

Description

Unit

Position of trolley

m

θ

The angle of load by direction of the trolley

rad

ϕ

Fluctuation angle of load

rad

γ

Angle of tower

rad

The moment that affects the tower

Nm

The force which affects the trolley

N

  1. System parameters

Symbol

Description

Value

Unit

m

Mass of load

0.32

kg

g

Gravitational acceleration

9.8

m/s2

L

Length of string

0.32

m

M

Mass of trolley

0.7

kg

Coefficient of motor A

5.58

NA

Coefficient of motor B

11.91

NA

The voltage applied for motor A

NA

V

The voltage applied for motor B

NA

V

  1. Side view of tower crane model

  1. Vertical view of tower crane model
  1. Anfis Toolbox In Generating Controller

In [17], PID controller is used well. In that research, a structure of two PID blocks is used for controlling x and θ (PID control 1). These variables belong to the trolley and the angle of load following the trolley’s direction. Another structure of two PID blocks is used for controlling ϕ and γ (PID control 2). These variables belong to the tower and the angle of load following the rotating direction of the tower. Thence, four blocks are used in the PID structure in [17]. To create an ANFIS block for controlling the model, a collecting program to obtain input-output data of the PID controller is designed in Fig. 3.

  1. Program to collect data for training ANFIS from PID controller

Eight random signals (from input 1 to input 8) are given to inputs of the PID structure. Two outputs (output 1 and output 2) are outputs of the PID controller. The data of these outputs are collected to identify the PID controller. The IDENT toolbox of MATLAB software collects data on inputs and outputs for each PID control and trains fuzzy blocks to imitate each PID control as in Fig. 4 and Fig. 5. After being trained, two fuzzy blocks are obtained. They replace PID controls 1 and 2 from the simulation program from [17]. So, we obtain a new fuzzy-ANFIS control program of simulation in Fig. 6.

Description of blocks in Error! Reference source not found. is listed as,

  1. Set point of the position of the trolley
  2. Set point of position of γ
  3. Fuzzy control 1 which imitates PID control 1
  4. Fuzzy control 1 which imitates PID control 2
  5. Block imitating tower crane. This block describes the dynamic equations of the tower crane
  6. Position of trolley
  7. Angle of θ
  8. Angle of γ
  9. Angle of ϕ
  10. “Comparison” block which stops simulation if values of variables are overvalued to prevent stuck simulation.

  1. Identification of PID Control 1
  1. Identification of PID Control 2

  1. Simulation program of fuzzy-ANFIS for tower crane

  1. simulation

The initial values of the system are chosen as

(5)

The system is controlled under a fuzzy controller as in Fig. 6. Simulation results are shown in Fig. 7 and Fig. 8. In Fig. 7, the angle of load takes only 2 seconds to be stable. This angle vibrates about 0.07 rad. The trolley needs 4 sec to be exactly at the expected position. The settling error is zero. Fuzzy control 1 (number 3 of Fig. 6) can control the trolley well and the angle of load in the trolley’s direction.

In Fig. 8, angle of load vibrates from -0.4 rad to 0.6 rad and takes 6 sec to be stable. The tower rotates from -0.2 rad to 0.6 rad and takes about 6 sec to be stable at the set point.

  1. Position of trolley (red), angle θ (blue) and set point of position for the trolley (black)

  1. Angle φ (red), angle γ (green) and set the point of angle of the tower (red)

V.  experiment

  1. Experimental Model

  1. Description of numbers in Fig. 9 is:
  2. Trolley
  3. The motor that controls the trolley
  4. Counterweight to balance model
  5. Register to measure θ, φ
  6. Load
  7. Motor that controls γ
  8. Tower
  9. Basement of tower
  10. Electrical and Electronics control board

To measure angles of load, a structure of resistors is shown in Fig. 10 and Fig. 11.

Description of components in Fig. 11 is:

  1. Resistor measuring θ
  2. Resistor measuring φ
  3. String
  4. Plastic block
  5. Load

  1. Experimental model [14]

  1. Mathematical model of a structure that measures angles of load

  1. Realistic structure of structure which measures angles of load
  1. Embedded Program

An embedded program to operate the fuzzy-ANFIS controller for the experimental model is shown in Fig. 12.

Description of blocks in Fig. 12 is:

  1. Block that registers Waijung blockset
  2. Block that registers UART
  3. Block that receives signals of the position of the trolley and angle θ of load. Components inside this block are shown in Fig. 13.
  4. Block that receives signals of angle  of tower and angle φ of load. Components inside this block are shown in Fig. 14.
  5. Fuzzy control 1 block that controls the position of the trolley and angle θ. Components inside this block are shown in Fig. 15.
  6. Fuzzy control 2 block that controls the angle  of tower and angle φ. Components inside this block are shown in Fig. 16.
  7. Block that transfers control signals to PWM and direction of the motor. Components inside this block are shown in Fig. 17.
  8. Block that collects data and transfers data to the computer. Components inside this block are shown in Fig. 18.

  1. The embedded program which is created by MATLAB/Simulink blocks for STM32F4

 

  1. Blocks of the embedded program that transfer signals from sensors to obtain the position of the trolley and angle θ of load

  1. Blocks of the embedded program that transfer signals from sensors to obtain the angle γ of tower and angle φ of load

  1. Inside view of block “Fuzzy control 1”

  1. Inside view of block “Fuzzy control 2”

  1. Inside block which transfers control signal 1 to DC motor 1

  1. Inside block which transfers control signal 1 to DC motor 2
  1. Experimental results

  1. Experiment 1

In this experiment, the set-point is all zeros. The initial values of the system are selected as

(6)

The response of the system is shown in Fig. 19 and Fig. 20. In Fig. 19, the trolley moves from -13 cm to 23 cm before being stable at the 4th second. The settling error of the position of the trolley is 1 cm. The angle of load vibrates from -12 degrees to 1 degree before settling at 3rd second. The settling error is 1 degree. This error is created by the uncertainty of the structure of the sensor in Fig. 10 and Fig. 11. The hole inside the plastic hole is the cause of this error. In order to decrease this error, this hole can be made tighter. However, the so-tight hole will make the motion of the string difficult, and the load is impossible to move.

 

  1. Position of trolley (cm) (red) and angle θ of load (degree) (green)

In Fig. 20, tower fluctuates from -3 degrees to 8 degrees. The settling time of motion of the tower is 2 sec. The settling error of this angle is about 1 degree. This settling error is created by the friction force of the tower. This factor is not regarded in dynamic equations from (1)-(4). The angle of load vibrates from -15 degrees to 4 degrees and settles after 2 sec.

  1. The angle γ of the tower (degree) (red) and the angle θ of load (degree) (green)

When set points are zeros, the trolley, tower, and load terminate the vibration fast, and the initial positions of the tower and trolley are kept well.

  1. Experiment 2

The set points are chosen as:

Experimental results are shown in Fig. 21 and Fig. 22.

  1. Position of trolley (cm) (red) and angle θ of load (degree) (green)

In Fig. 21, setting time of motion of the trolley is 12s. The vibration of the angle is from -1 degrees to 2 degrees and settling error of nearly 2 degrees. The big settling error is caused by mechanical structure (disadvantages of structure of resistors). Due to the structure of the resistors, the vibration of load by the direction of the trolley is not big and not fluent. However, the survey of the angle of load still describes the features of the system. Besides, the encoder sensor of the trolley works well and the survey of motion of the trolley is good in this case. The signal of motion of the trolley moves fluently and this variable is controlled well  

In Fig. 22, the tower needs 4 sec to move to the set-angle. The settling error in this case is nearly zero. Its vibration is small. Also, the vibration of the angle of load terminates just in 4 sec and the settling error is zero.  In this case, the vibration of the angle of load through the tower axis is more fluent than the vibration of the angle of load through the trolley’s direction (in Fig. 21). The structure in Fig. 11 supports better the angle of load under the rotation of the tower than under the trolley’s direction. Through this experiment, from Fig. 21 and Fig. 22, when set-points are not zeros, the system still works well under fuzzy –ANFIS controller.

  1. The angle γ of the tower (degree) (red) and the angle θ of load (degree) (green)
  1. conclusion

From this research, from a former PID control platform for tower cranes, we utilize the ANFIS toolbox to create a fuzzy control structure. This controller imitates the PID controller to follow the idea that intelligent control learns from the experiences of experts. This controller is proven to control well the position of the trolley and the angle of the tower in both zero set-point and expected non-zero set-point. Moreover, the vibration of the load is terminated through operation. From this study, it is obvious that intelligent control can be utilized for STM32F4 to control the MIMO under-actuated model which is presented by tower crane in this case. Furthermore, this research confirms the ability of the fuzzy control method to imitate the control ability of the expert- PID controller in this case- for MIMO under-actuated models. Also, the tower crane, through this paper, can be a standard model for research and training in laboratories of universities for intelligent control besides linear control. However, the disadvantage of sensor structure (in Fig. 11) is shown due to the vibration of signals. A replacement for this structure is necessary. A solution of using two MPU6050 sensors to measure the angle of each direction can be used in the future.  

Acknowledgment

This paper belongs to the project which is funded by HCMUTE for students of HCMUTE in the year 2025. It is developed from the Bachelor thesis of Mr. Ngoc-Truong-Son Nguyen with the cooperation of Mr. Trung-Dung Nguyen under the supervision of Ms. Eng. Thi-Hong-Lam Le. We also want to give thanks to the PhD. Van-Dong-Hai Nguyen (HCMUTE) in his help in operating this hardware. We, the authors, appreciate this support.

References
  1. D.-A.-Q. Nguyen et al., “Adaptive Evaluation of LQR Control using Particle Swarm Optimization for Pendubot,” JFSC, vol. 2, no. 2, pp. 58–66, 2024, https://doi.org/10.59247/jfsc.v2i2.203.
  2. M.-Q. Nguyen et al., “Fuzzy Controller from Experts’ Rules for Middle Axis Ball and Beam”, JFSC, vol. 1, no. 3, pp. 80–84, 2023. https://doi.org/10.59247/jfsc.v1i3.94.
  3. P. Hyla, "The crane control systems: A survey," 2012 17th International Conference on Methods & Models in Automation & Robotics (MMAR), pp. 505-509, 2012, https://doi.org/10.1109/MMAR.2012.6347867.
  4. T. Ronte, Y. Nakamura and S. Wakui, "Switching control of an air type anti-vibration apparatus under earthquake ground motion," IECON 2013 - 39th Annual Conference of the IEEE Industrial Electronics Society, pp. 3788-3793, 2013, https://doi.org/10.1109/IECON.2013.6699739.
  5. S. Bonnabel and X. Claeys, "The Industrial Control of Tower Cranes: An Operator-in-the-Loop Approach [Applications in Control]," in IEEE Control Systems Magazine, vol. 40, no. 5, pp. 27-39, 2020, https://doi.org/10.1109/MCS.2020.3005256.
  1. R. Čápková and A. Kozáková, "Experimental Modelling and Control of a Tower Crane," 2019 22nd International Conference on Process Control (PC19), pp. 97-101, 2019, https://doi.org/10.1109/PC.2019.8815327.
  2. L. T. Aboserre and A. A. El-Badawy, “Robust integral sliding mode control of tower cranes,” Journal of Vibration and Control, vol. 27, no. 9-10, pp. 1171-1183, 2021, https://doi.org/10.1177/1077546320938183.
  3. Z. Sun and H. Ouyang, “Adaptive fuzzy tracking control for vibration suppression of tower crane with distributed payload mass,” Automation in Construction, vol. 142, 2022. https://doi.org/10.1016/j.autcon.2022.104521.
  4. V. D. H. Nguyen et al., “Experimental Fuzzy Control for Tower Crane,” Journal of Technical Education Science, no. 68, pp. 36-47, 2024, https://doi.org/10.54644/jte.68.2022.1121.
  5. Y. A. Badamasi, "The working principle of an Arduino," 2014 11th International Conference on Electronics, Computer and Computation (ICECCO), pp. 1-4, 2014, https://doi.org/10.1109/ICECCO.2014.6997578.
  1. H.-T. Nguyen et al., “Experiment Ball Levitation with Fuzzy PID and PID Implementation,” JFSC, vol. 2, no. 3, pp. 129–134, 2024. https://doi.org/10.59247/jfsc.v2i3.221.
  2. Thi-Ai-Van Nguyen et al., "PID Control for Heating Oven by Matlab-Embedded Arduino," Robotica & Management, vol. 28, no. 1, pp. 36-42, 2023, https://doi.org/10.24193/rm.2023.1.5.
  3. C.-H. Nguyen et al., “ANFIS-based LQR Control for Rotary Double Parallel Inverted Pendulum”, JFSC, vol. 2, no. 2, pp. 109–116, 2024, https://doi.org/10.59247/jfsc.v2i2.214.
  4. P. Olejnik, P. Adamski, D. Batory, and J. Awrejcewicz, “Adaptive Tracking PID and FOPID Speed Control of an Elastically Attached Load Driven by a DC Motor at Almost Step Disturbance of Loading Torque and Parametric Excitation,” Applied Sciences, vol. 11, no. 2, p. 679, 2021, https://doi.org/10.3390/app11020679.
  5. S. Istiqhara et al., “Enhanced Equation Discovery of 3-DoF Robotic Manipulator Dynamics Using LASSO Model Selection Criteria With Variable Segregation Algorithm,” IEEE Access, vol. 12, pp. 20574-20590, 2024, https://doi.org/10.1109/ACCESS.2024.3354374.
  1. J. Wang et al., “Neural network and Sparse Identification of Nonlinear Dynamics Integrated Algorithm for Digital Twin Identification,” IFAC PapersOnLine, 56-2, pp. 6921–6926, 2023. https://doi.org/10.1016/j.ifacol.2023.10.503.
  2. Minh-Tam Nguyen et al, “PID Control to Decrease Fluctuation of Load for Tower Crane,” Robotica & Management, vol. 26, no. 2, pp. 22-27, 2021, https://doi.org/10.24193/rm.2021.2.4.  

Ngoc-Truong-Son Nguyen, An Application of STM32F4-Embedded ANFIS-Fuzzy Controller for Tower Crane