## 3 Description of the Control System
The control method of a BLDC motor is strongly dependent on the shape of the back electromotive force induced on the unused phase. In the case of a trapezoidal shape, the input signals generated thorough Hall sensors are used to specify the current rotor position. Based on the received information, a specific pair of transistors in a closely determined time window is switched. In the case of a sinusoidal shape of the back-EMF, an FOC control structure is often implemented [34]. The main idea of FOC (field-oriented control) is to control the stator current components related to the rotor flux. Because of the given structure, it is possible to ensure full torque control in dynamic states of the electric drive. This feature is essential in robotics. Analyzing the placement of vectors shown in Figure 2, the stator current vector (\(i_{s}\)) can be divided into two components. The first one (\(i_{sd}\)) is related to the flux, while the second one influences the actual torque value (generated inside the motor). In the brushless motor, the flux is generated by the set of permanent magnets placed on the rotor surface. Thus, the \(i_{sd}\) current component needs to equal zero. The second component (\(i_{sq}\)) corresponds to the stator current vector and affects its value directly. Increasing the \(i_{sq}\) component value is forced to keep the torque at a desired level. The adjustment depends on the operation stage of the machine and the actual torque load. One of the main advantages of the application of the field-oriented control method is the similarity to the cascade control of a conventional DC motor. The separate path for the electromagnetic torque, \(m_{e}\), control is noticed. It is related to the mathematical equations describing the value of the signal:  
\[m_{e}=\Psi_{w}\cdot i_{t}=const\cdot i_{t}, \tag{1}\]  
\[m_{e}=\Psi_{PM}\cdot i_{q}=const\cdot i_{q}. \tag{2}\]  
Two main control paths may be distinguished in the FOC structure. The first one consists of two PI controllers (Figure 3). The first one is related to the main state variable, and processes the speed error and generates the reference value for internal part of the system [35; 36; 37]. The analyzed controller calculates the \(i_{sq}\) component corresponding the torque value. The second path contains a controller that forces the \(i_{sd}\) component to zero. The speed above the nominal value may be obtained by decreasing the \(i_{sd}\) component to below zero. For BLDC  
Figure 1: The topology of microcontroller system used for remote control of wheel-legged robot. motors, the flux angle, required to make a proper Park's transformation, corresponds to the rotor position directly [38]. The final output signals from the current controllers are used after recalculation of the inverse Park transformation block. Obtained signals are provided to the space vector modulation (SVM) unit, which controls the transistors in the power module. In the proposed construction of the robot, the FOC has been implemented in STM32F103R. The second part of the main system was responsible for control of the chassis level. The algorithm was implemented in Raspberry Pi Pico, which is a powerful development board based on a dual-core ARM Cortex M0+ chip. This unit is equipped with a variety of communication protocols (e.g., 2 xSPI, 2x12C and 2 xUART) and 26 GPIO pins. Moreover, Raspberry Pi Pico gives a wide range of advanced peripheral extensions, which are perfectly suitable for creating a drive system (e.g., ADCs and PWM generator). The advantage of the Raspberry Pico over other popular microcontrollers is related to easy accessibility and uncomplicated software. The software may be developed using Arduino IDE. Additionally, the embedded code can be directly written in both C and Python programming languages [39]. The Raspberry Pi Pico unit acquired the data from the MPU605 sensor. The device was equipped with an on-board gyroscope and accelerometer, and provided information to control the chassis level. The communication between devices was realized using an I2C protocol.