Wheel-Leg Robot Design and Implementation

Overall Scheme Design

Overall Structure Design

The wheel-leg robot (LeTian-robot2) utilizes a linkage mechanism (see Figure 1), with the linkage controlled by servos. By controlling the servos on both sides, the overall tilt and lift of the body can be achieved. The feet are directly driven by a 4010 brushless motor without any reduction gear. Figure 2 shows the components used to build the wheel-leg robot, while Figures 3 and 4 show the PCB and the electronic components connected to the PCB.

Wheel-Leg Robot Design and Implementation

Figure 1 3D Model of the Wheel-Leg Robot

Wheel-Leg Robot Design and Implementation

Figure 2 Component Display for Building the Wheel-Leg Robot

Wheel-Leg Robot Design and Implementation

Figure 3 PCB Front

Wheel-Leg Robot Design and Implementation

Figure 4 PCB Back

Circuit Design
1. Main Control Chip Selection

ESP32-S3 (see Figure 5) is a MCU chip that supports 2.4GHz Wi-Fi and Bluetooth 5 (LE), allowing for long-distance mode. The ESP32-S3 is equipped with a Xtensa 32-bit LX7 dual-core processor, with a maximum frequency of 240MHz, built-in 512KB SRAM (TCM), 45 programmable GPIO pins, and a rich set of communication interfaces. The ESP32-S3 supports larger capacity high-speed Octal SPI Flash and external RAM, allowing for user-configurable data and instruction caches.

Wheel-Leg Robot Design and Implementation

Figure 5 Main Control Chip ESP32-S3

2. Brushless Driver Selection

DRV8313 provides three independently controllable half-bridge drivers. It can drive three-phase brushless DC (BLDC) motors and can also be used to drive solenoids or other loads. It is primarily used to drive a three-phase brushless DC motor in the wheel-leg robot. Each output driver channel uses N-channel power MOSFETs in a half-bridge configuration. This design connects the ground terminal of each driver to a pin to perform current sensing on each output. DRV8313 provides up to 2.5A peak current or 1.75A RMS output current on each channel of the half-bridge (with proper PCB heat dissipation at 24V and 25℃). This component offers internal shutdown features for overcurrent protection, short-circuit protection, undervoltage lockout, and over-temperature motor protection. The brushless motor driving circuit is shown in Figure 6.

Wheel-Leg Robot Design and Implementation

Figure 6 Brushless Motor Driving Circuit

3. Current Sampling Circuit
Figure 7 shows the current sampling circuit. INA240 is a current sensing amplifier that outputs a voltage, featuring enhanced PWM (Pulse Width Modulation) suppression capabilities to detect the voltage drop across the shunt resistor in a common mode voltage range of -4 to 80V, independent of supply voltage. Negative common mode voltage allows the device to operate below ground voltage, accommodating the back EMF typical in solenoid applications. The enhanced PWM suppression capability provides high levels of suppression for large common mode transients (ΔV/Δt) in systems using PWM signals (like motor drive and solenoid control systems). This feature enables precise current measurements without significant transients in output voltage and corresponding recovery ripple.

Wheel-Leg Robot Design and Implementation

Figure 7 Current Sampling Circuit

This component operates on a single supply voltage of 2.7~5.5V, with a maximum supply current of 2.4mA. There are four fixed gain options available: 20, 50, 100, and 200. This series of components features zero-drift temperature architecture and low offset, allowing for current detection with a maximum voltage drop of 10mV (full scale) across the shunt resistor. All versions have an extended rated operating temperature range (-40~125℃) and are available in 8-pin TSSOP and 8-pin SOIC packages.
4. Motion Sensor Selection
MPU 6050 (see Figure 8) is a 6-axis motion sensor. It integrates a 3-axis MEMS gyroscope, a 3-axis MEMS accelerometer, and an expandable digital motion processor (DMP) that can connect to third-party digital sensors, such as magnetometers, via the I2C interface. Once expanded, it can output a 9-axis signal through its I2C interface. The MPU 6050 uses three 16-bit ADCs for the gyroscope and accelerometer respectively, converting the measured analog quantities into output digital quantities. To accurately track rapid and slow motion, the sensor’s measurement range is user-controllable. The gyroscope measurement range is ±250°/s, ±500°/s, ±1000°/s, ±2000°/s, and the accelerometer measurement range is ±2g, ±4g, ±8g, ±16g.

Wheel-Leg Robot Design and Implementation

Figure 8 Motion Sensor MPU 6050

5. MCU Power Supply Scheme
SPX3819 (see Figure 9) is a linear voltage regulator with low dropout and low noise output, providing 800µA of low ground current at a 100mA output. The initial tolerance of SPX3819 is less than 1% of the maximum value, and it features a logic-compatible on/off switching input. Power consumption drops to nearly zero when disabled. Other key features include battery reverse protection, current limiting, and thermal shutdown. SPX3819 includes a bypass pin for optimal low-noise output performance. With an extremely low output temperature coefficient, this component also features excellent low-power voltage reference. SPX3819 is suitable for battery-powered applications such as cordless phones, radio control systems, and portable computers. It is available in several fixed output voltages or adjustable output voltages.

Wheel-Leg Robot Design and Implementation

Figure 9 SPX3819
6. Automatic Programming Circuit

The ESP32-S3 has two modes: SPI boot mode (normal boot) and download boot mode. To achieve automatic program downloading, it must automatically enter download boot mode upon power-up, which is achieved by pulling GPIO0 and GPIO2 low simultaneously. Since GPIO2 is pulled down by default when powered on (GPIO2 may be used for reading/writing SD cards or have other functions, leading to download failures if a device is connected and the pin is high), only GPIO0 can be considered while controlling the reset pin (EN) to achieve automatic program downloading. As shown in the circuit in Figure 10, the transistor selected is the NPN type S8050, with external control signals being nDTR and nRTS, which are used on the development board as the emulator pins (JTAG emulator). However, it is not necessary to use a JTAG emulator for downloading, as the ESP32-S3 supports direct serial downloading, so these two pins can be directly used with the corresponding pins of CH340K.

Wheel-Leg Robot Design and Implementation

Figure 10 Automatic Programming Circuit

7. Servo Power Selection
LM2596 is a non-synchronous buck power management integrated circuit capable of outputting 3A of drive current while providing good linear and load regulation characteristics. The LM2596 internally contains a 150kHz oscillator, a 1.23V reference voltage circuit, thermal shutdown circuit, current limiting circuit, amplifier, comparator, and internal voltage regulation circuit. The input voltage range is 4.5~40V, allowing it to provide up to 3A of DC load current. When the internal switch of the LM2596 is turned on, the 12V voltage charges L1 and C2, C3 from pin 2 of the IC to power the load, with L1 and C2, C3 storing energy. When the internal switch of the LM2596 is turned off, pin 2 of the IC no longer outputs 12V, and L1 maintains the load current (magnetic energy converted to electrical energy), with VD3 conducting to provide the discharge current loop for L1. Meanwhile, Cout also discharges, causing the voltage to drop slightly. This voltage is compared with the reference voltage through pin 4 of the IC, and when it falls below the reference voltage, the internal switch of the IC turns on again to begin the next cycle. The servo driving circuit is shown in Figure 11.

Wheel-Leg Robot Design and Implementation

Figure 11 Servo Driving Circuit

8. Brushless Motor Magnetic Sensor Chip
AS5600 is a programmable magnetic rotary position sensor with high resolution, offering 12-bit analog or PWM output. This non-contact system can detect the absolute angle of rotation of a magnet along its radial magnetic axis. The AS5600 is designed for non-contact potentiometer applications, and its robust design eliminates the influence of homogeneous external stray magnetic fields. The standard I2C interface supports simple non-volatile parameter user programming without the need for a dedicated programmer. The default output range is 0~360°, which can also be programmed to set the zero angle (starting position) and maximum angle (stopping position) for a smaller output range. The AS5600 also features an intelligent low-power mode to automatically reduce power consumption. The input pin (DIR) selects the output polarity related to the rotation direction. If DIR is grounded, the output value increases with clockwise rotation; if DIR is connected to VDD, the output value increases with counter-clockwise selection. The magnetic sensor AS5600 circuit is shown in Figure 12.

Wheel-Leg Robot Design and Implementation

Figure 12 Magnetic Sensor AS5600 Circuit

Program Design

Overall Hardware Connection

The overall hardware connection is shown in Figure 13, with the main control chip using ESP32-S3, reading the MPU 6050 gyroscope and accelerometer data via the I2C interface, displaying data via SPI to the display, reading microphone data and driving the amplifier via the I2S interface, and driving the servo and motor via PWM signals.

Wheel-Leg Robot Design and Implementation

Figure 13 Overall Hardware Connection

Program Writing

Programming is temporarily done using the PlatformIO platform in Visual Studio Code to set up the Arduino environment for the ESP32-S3 chip, utilizing ESP32-RTOS to run programs on both cores of the ESP32-S3 simultaneously. The brushless motor drive utilizes the FOC algorithm, with the driver chip being DRV8313. The wireless function uses the low-power Bluetooth built into ESP32-S3, using the blinker library and the mobile endpoint lighting technology App for wireless connection and control.

First, initialize the motor, magnetic sensor, gyroscope, servo, and Bluetooth (see Program 1), and set the PID parameters for the motor FOC algorithm accordingly (see Program 2), including parameter settings for the gyroscope and accelerometer, initialization of the servo standard signal, and design of the balancing algorithm and creation of the motor FOC algorithm.

Wheel-Leg Robot Design and Implementation

Wheel-Leg Robot Design and Implementation

Wheel-Leg Robot Design and Implementation

Wheel-Leg Robot Design and Implementation

Program 3 shows the reference program for motor FOC algorithm computation, wireless communication with the lighting technology App, and servo control tasks.

Wheel-Leg Robot Design and Implementation

The balancing algorithm uses the classic cascade PID algorithm, assuming the motor control model is linearized, dividing the traditional cascade PID into balance loop, speed loop, and steering loop, and directly performing linear superposition to control the motor (see Program 4).

Wheel-Leg Robot Design and Implementation

Wheel-Leg Robot Design and Implementation

The entry parameters for the balance loop control are the body angle and angular velocity, with the return value being the upright loop motor torque control value (see Program 5).

Wheel-Leg Robot Design and Implementation

The entry parameters for the speed loop control are the actual speed values of the left and right motors, with the return value being the speed loop motor torque control value (see Program 6).

Wheel-Leg Robot Design and Implementation

Wheel-Leg Robot Design and Implementation

The entry parameters for the steering loop control are the angular velocity of rotation around the Z-axis, with the return value being the steering loop motor torque control value (see Program 7).

Wheel-Leg Robot Design and Implementation

Conclusion

Currently, this project has completed the balance function of the vehicle and the wireless control function. Bluetooth connection allows control of the vehicle’s movement, as well as adjustments to the body height and tilt, though it currently does not support adaptive adjustment of the left and right servos to maintain a constant body height. Future development will shift to the ESP32-IDF environment, while continuing to optimize the control algorithm. The PCB has reserved interfaces for speakers and microphones with I2S, and since the ESP32-S3 supports offline voice recognition, offline voice control functions will be added later. The LCD interface supports a 1.28-inch circular LCD, connected with an 8Pin FPC ribbon cable, and has reserved a TF (Micro SD) card interface to support LVGL animation interaction in the future.

There are still many shortcomings in this design and production, such as further optimization of the linkage mechanism of the vehicle body, which will be improved through MATLAB simulation to better serve the control algorithm.

Text and images are sourced from Radio Magazine

Initial Review: Tang Cuimei

Second Review: Huo Xiaoyin

Final Review: Wang Xianfang

Wheel-Leg Robot Design and Implementation

Leave a Comment