Design of dancing robot control system based on STM32

Abstract. Dancing robot control system for children's entertainment is introduced. In order to achieve better interaction, this robot use the ARM core chip STM32 as the control core, Bluetooth module as the means of wireless communication, and smart phones as the face display screen and motion controller of dance robots. Experimental results show that the robot is stable, it can work given dance actions. The robot is good operable and maintainable.


Introduction
In the field of service robot research, which started earlier in foreign countries, but domestic scholars have done a lot of research in this area and achieved certain achievements so far. A number of universities and research institutes such as University of Science and Technology of China, Shanghai Jiao Tong University, Harbin Institute of Technology and Institute of Automation of, Chinese Academy of Sciences have also successfully developed various entertainment robots, monitoring robots, rescue robots and so on [1] . With the development of the era of intelligent information, intelligent and technological household products are mainly concentrated in the technical field of accompanying children, such as building blocks, smart phones, toy dialogs and so on.
Due to the increase of working pressure, parents spend less time accompanying their children, which will attract more attention from society. The market demand of accompanying robots will continue to increase, which makes the research in this area also attracted a lot of attention and attention [2] . This robot is a parallel robot, controlled by the STM32 microcontroller, and its movement is flexible and variable, which increases entertainment.  STM32F103 module is an embedded microprocessor chip based on the Cortex-M 3 core, and it is the first RISC instruction processor based on the ARMv7-M architecture 32-bit standard. STM32F103RET6 is characterized by its abundant internal resource allocation, high performance, low cost and low power consumption, so it has a wide range of applications in the embedded field.

Six-axis position detection module
The six-axis position detection module is mainly composed of a rotary potentiometer and a filter resistance [3] . Its potentiometer resistance value is 10k, linearity is ±2%, the supply voltage is 3.3V, that is, the potentiometer rotates 0-30° corresponding to 0-3.3V. The signal terminals of six six-axis position detection modules are respectively connected with PA1-PA6. Its interface circuit is shown in Figure 2.

Chassis posture detection module
This module uses InvenSense's MPU6050 chip as its core, MPU6050 is the world's first 9axis motion processing sensor. The chip integrates 3-axis gyroscope and 3-axis accelerometer, and can use the hardware acceleration engine of its own digital motion processor to output attitude calculation data to the application end through IIC interface. In addition, the module is compatible with 3.3V/5V system. Its interface circuit is shown in Figure 3.

Walking speed detection module
The module is an incremental hall encoder installed at the tail of the traveling motor [4] . The output signal of the encoder is orthogonal AB phase, which is a standard square wave. STM32 has its own encoder interface, which can directly use hardware counting to determine the rotation direction and speed of the motor. Its interface circuit is shown in Figure 4.

Obstacle avoidance module
Infrared photoelectric sensor is a kind of photoelectric proximity switch. It detects the presence or absence of an object by means of the shading or reflection of the detected object to the infrared beam and being selected by the synchronous circuit. The infrared sensor is used to detect whether there are obstacles and cliffs around the dancing robot, so as to realize the automatic obstacle avoidance function of the dancing robot [5] . Its interface circuit is shown in Figure 5.

Wireless module
Bluetooth technology has a strong versatility, mainly used in the 2.4 GHz band. It is a wireless communication protocol based on IEEE802.15 standard, and is usually used as the standard of intelligent terminal. In this paper, STM32 MCU is used as the control core, and Bluetooth module receives the control signal transmitted by mobile phone to realize the control of the dancing robot [6] .

DC motor driving module
DC motor is driven by L298N module. And it uses PWM to adjust its speed. PWM uses rectangular pulse waves with fixed amplitude while the pulse width is adjusted during each period [7] . By changing the amplitude of armature voltage, the purpose of changing the speed of DC motor is achieved. The PID controller is loved by most operators because of its simple structure, high reliability and easy operation. Six-axis motor is controlled by position-speed double-loop PID, while walking motor is controlled by speed-loop PID.

System software design
The system first judges the Bluetooth signal, and then the dancing robot receives the control mode of APP through Bluetooth communication to perform special actions according to different modes.

Software image processing on mobile phone
The image processing process is divided into the following steps: Firstly, most of the noise background is removed and the edge boundaries of human contour are obtained by morphological gradient operation, The shape edges of each frame are accumulated in an image. Secondly, the grid-based directional gradient histogram is calculated and the image motion feature vector is obtained by accumulating edge images. After obtaining the angle of each joint, the mobile phone transmits the position of each joint to the STM32 controller. After receiving the position of each joint, the STM32 controller controls the six-axis deceleration motor to rotate a specific angle to achieve motion reproduction.

Summary
In this paper, a dancing robot for family entertainment is designed. The components of the robot control system and the realization of its functions are studied, so as to improve the entertainment of the family. At the same time, the robot has reserved interfaces to facilitate secondary development.