STM32 medical rehabilitation robot arm control system

Publisher:Tianyun2021Latest update time:2018-08-13 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: Medical rehabilitation robot is a new type of robot that has appeared in recent years. Its main function is to help patients complete various motor function recovery training. To this end, it is proposed to control the operation of the robot arm by controlling the brushless DC motor through the STM32 microcontroller, and establish a PID model through Simulink , and use XPC_Target to communicate with the control board to obtain the appropriate PID parameters of the motor during the speed regulation process, so that the robot arm can operate more smoothly. The actual clinical trial operation proves that the system can better complete the medical rehabilitation training of the arm.

As my country gradually enters an aging society, the demand for various types of rehabilitation equipment is increasing, and the demand for cost-effective medical rehabilitation equipment control systems is particularly urgent. DSP chips are relatively expensive, complex in design, and have a long R&D cycle. The size of the chip will lead to a larger printed circuit board.

This article designs a medical rehabilitation robot arm control system based on the STM32 microcontroller . It has an advanced timer for outstanding power consumption control and motor control, and can generate three pairs of configurable and complementary output PWM signals. By building a double closed-loop PID algorithm model on Simulink , the appropriate PID parameters are obtained to change the duty cycle of the PWM wave, and then the motor speed is accurately adjusted, ensuring the smooth running trajectory and stable running speed of the robot arm. Due to the advantages of small size and stable performance of brushless DC motors, the size of the robot arm can be more in line with the design concept of human kinematics.

1 Overall design

The medical rehabilitation robot arm can simulate some arm movements in daily life and achieve movement training of each arm joint, muscle training, and nerve function recovery training by creating a virtual working environment. With the STM32 microcontroller as the control core, the overall design scheme of the robot arm control is shown in Figure 1.

By using the IR2130 gate driver chip, the 6-channel PWM signals output by STM32 are specially processed to meet the working requirements of the IRF3808 high-power MOS tube in the H-bridge.

The STM32 microcontroller controls the operation of the motor by changing the commutation timing by continuously detecting the Hall signal in the brushless DC motor. When the motor is stalled, it will generate a large current, and the current value will be sampled through the ADC. When the value exceeds the threshold, the motor can be stopped. At this time, the IR2130 will automatically enter the self-protection state and shut down the output signal to ensure the safety of the arm operation.

2 Hardware Circuit Design

2.1 Gate drive

The gate drive chip uses the IR2130 chip from International Rectifier, which has high voltage, high speed, and 3 independent high and low side power MOSFET drive output channels. Its input and output signal timing is shown in Figure 2. It has over-current protection and under-voltage lockout functions, and can shut down 6 outputs in time. When an abnormal state occurs, the inverter circuit is in the off state, which can protect the motor from burning out and has a self-protection function.

Three of the six output signals have level conversion functions, so they can drive both the low-voltage side power devices and the high-voltage side power components in the bridge circuit. As shown in Figure 3, the three pairs of complementary PWM signals output by the STM32 to drive the H-bridge are increased to a voltage level that can drive the MOSFET switch.

One IR2130 can replace three IR2110s and only requires one input stage power supply to automatically generate the dead zone required for upper and lower side driving with a time of 2.5μs and obtain better control performance.

2.2 H-bridge power circuit

High-power FETs can output high voltages. The inverter circuit is mainly composed of 6 high-power FETs IRF3808, as shown in Figure 4. Each FET is connected in parallel with a reverse-connected fast recovery diode, which has the function of protection and freewheeling. For a 24 V motor, the VDS of the FET requires at least 40 V, and the drain current must be high enough to cope with the motor starting current. The starting current can be further reduced due to the soft acceleration mechanism implemented in the software (a small increase to the required speed).

2.3 Current detection circuit

Use a 0.01 Ω current detection resistor or a serpentine ground wire, and all the currents passing through the motor and MOSFET pass through it and flow to the ground. As shown in Figure 5, the total current passing through the motor flows to the ground through this small resistance resistor. The resistance of this current detection resistor is very small, but if the current is large enough, a small voltage will be generated at both ends. The first-order low-pass filter circuit formed by RC can filter out some occasional instantaneous high-frequency components. Its cut-off frequency can be calculated by the specific value of RC. Finally, it can be connected to the ADC channel of STM32 for current acquisition.

2.4 Motor Torque

For the motor, the robot arm is under load during operation, so there must be enough torque to ensure the normal operation of the arm. Like speed control, the torque is also determined by the current through the stator coil. The maximum torque and the angle between the stator and rotor magnetic fields should be maintained at 90°. Trapezoidal commutation is shown in Figure 6. The control resolution is 60°, and the angle between the stator and rotor magnetic fields is in the range of -30° to +30°, which will produce torque pulsation.

The RC low-pass filter in the current detection process can filter out the high-frequency instantaneous pulses flowing into the motor and improve the motor torque characteristics. When changing the direction of operation, in order to obtain a relatively large torque, the direction of operation is changed directly, and the robot arm direction is changed by running-stopping-reverse running. This can prevent the robot arm from shaking when turning, and also prevent the starting current from being too large when starting again, which is prone to stalling and damage to the hardware circuit and motor.

3 Software Design

3.1 μC/OS—II Operating System

In order to make the software architecture more stable and clear, a curable, customizable, preemptive multi-tasking real-time operating system μC/OS-II is used. It is a preemptive real-time kernel based on priority scheduling, and provides the most basic system services on top of this kernel, such as semaphores, mailboxes, message queues, memory management, interrupt management, etc.

On the μC/OS-II embedded operating system, the priority of the Hall signal capture interrupt, host computer communication interrupt, ADC acquisition interrupt, and PID speed regulation interrupt in the brushless DC motor is allocated, and the software operation is made more modular by creating tasks such as the direction of operation, start, stop, host computer communication, and PID regulation of the medical rehabilitation arm. Information is transmitted between tasks through mailboxes, message queues, etc., and corresponding tasks can be suspended and started mutually, so that tasks can work in coordination and the software architecture is clearer.

3.2 Motor speed measurement and six-step commutation

The actual speed of the brushless DC motor can be obtained by measuring the Hall sensor signal. During the rotation of the motor, three periodic signals as shown in Figure 7 can be obtained through three Hall sensors distributed 120 degrees in the motor.

Each time the motor rotates one circle, each Hall sensor generates a 2-cycle square wave signal, and its cycle is inversely proportional to the motor speed. Its structure is more convenient and flexible than adding an encoder to the periphery.

The timer of the STM32 microcontroller has a port for detecting Hall signals. The timer performs XOR processing on the three Hall signals detected. When it can capture the rising edge, it triggers an interrupt request. The time required to generate this interrupt is recorded in the interrupt, and the timer is cleared. The control process operation is shown in Figure 8. The average value is calculated through several interrupt times, and the obtained time average value is converted into the speed value of the motor. The motor 6-step commutation timing is performed by the high and low level values ​​of the three Zhai Er sensors detected, which can make the brushless DC motor operate according to the timing requirements.

3.3 Motor PID Algorithm

Since both the human arm and the robot arm structure have weight, they will be affected when the motor is running, causing the motor speed to change continuously, which is not conducive to the stable operation of the robot arm. Therefore, it is necessary to perform a double closed-loop PID operation on the measured speed value and the set speed value to keep the motor running speed at the set speed value. As shown in Figure 9, the PID algorithm of the motor is implemented by changing the duty cycle of the phase voltage pulse width modulation (PWM) wave. By increasing or decreasing the duty cycle, part of the current will flow through the stator coil in each commutation step, which will affect the stator magnetic field and magnetic flux density, thereby changing the force between the rotor and the stator.

By obtaining the difference between the set value of the brushless DC motor speed (set by the host computer) and the actual detected motor speed value, PID adjustment is performed through the speed PID control loop and the current PID control loop to change the duty cycle of the PWM wave of the STM32 output drive motor operation signal, so that the robot arm can run smoothly and stably.

4 PID model design

The real-time target system XPC_Target based on the RTW framework developed by MathWorks is used for modeling, which provides a low-cost, high-performance system that can be easily used in real time. The host + target machine technology is adopted, that is, the "dual machine" mode. The host and target machines can be different types of computers, and the two communicate through Ethernet. The implementation model is shown in Figure 10.

According to the working principle, its implementation is divided into the following steps:

(1) Use a USB drive to create a DOS target boot disk

There are three modes of boot disk: FDD, HDD and ZIP. You can choose the mode supported by the target machine during the production process. You can make the target boot disk by selecting the embedded option of XPC_Target. By calling and starting the real-time kernel of XPC_Target through a USB flash drive, you can automatically run the target application every time the system starts.

(2) Simulink model establishment

By adding various driver modules on the host machine's Simulink, the PID models of the current loop and speed loop in the motor speed regulation process and the serial communication module of the lower machine are established. Then, the RTW code generator and C compiler are used to generate executable code for real-time operation on the target machine.

(3) Signal acquisition process

The signal data of the target application is stored in the RAM of the target machine through the XPC_Target real-time kernel, and the signal is monitored, recorded, tracked, and drawn on the display interface of the target machine. When the lower computer sends the speed measurement value to the executable code generated by the PID model established in Simulink running on the target machine through the serial port, the speed is adjusted through the executable code program, and the adjusted data is sent to the lower computer through the target machine, thereby changing the PWM wave duty cycle of the drive motor operation signal. When its speed measurement value can stabilize to the speed setting value, the PID parameters set in Simulink are the PID parameter values ​​required for speed adjustment. Otherwise, the PID parameter model established in Simulink needs to be changed.

Conclusion

This paper proposes a control system for a medical rehabilitation robot arm based on an STM32 microcontroller . At present, the prototype of this system has been clinically tested and has achieved good experimental results. The robot arm in the experiment has three degrees of freedom and can realize the training of shoulder joints, elbow joints, etc. By using the IR2130 gate driver chip, the board size, system stability and design flexibility are improved. The PID parameter model is designed on Simulink, and the brushless DC motor is driven by the STM32 microcontroller driver board. At the end, the trainer's arm is driven to train on fixed trajectories in the horizontal and vertical planes respectively, and the collected running trajectory, speed image, and the pre-set arm running trajectory and speed image are compared and observed. The robot arm runs smoothly and the PID parameters are stable, which further enhances the stability and flexibility of the system.


Reference address:STM32 medical rehabilitation robot arm control system

Previous article:Design of a fall alarm based on inertial sensing technology
Next article:Fluke SigmaPace 1000 External Pacemaker Analyzer is here to protect you

Recommended ReadingLatest update time:2024-11-23 10:31

STM32 standard peripheral library function SetSysClockTo72(void)
The article http://blog.csdn.net/qq_29344757/article/details/73479924 introduces the clock system of STM32. Now, taking the SetSysClockTo72() function of the STM32 standard peripheral library as an example, we will introduce the programming of RCC. With the foundation of the previous article, learning RCC is no long
[Microcontroller]
STM32 standard peripheral library function SetSysClockTo72(void)
STM32 IO port settings
1. When the IO port is used as a button: if the button is pressed at a low level, the IO port should be set to a pull-up input; if the button is pressed at a high level, the IO port should be set to a pull-down input. 2. KEIL4.7 version has a grammar check function. Today I found that when the folder is in uppercase E
[Microcontroller]
STM32 learning external interrupt
I read the introduction of external interrupts online before and thought it was very simple. Now I think it was really impetuous to have such an idea. Don't be an impetuous embedded engineer, you must be down-to-earth. Today I did an external interrupt experiment. I didn't know until I tried it. I didn't get it done th
[Microcontroller]
Cortex entry stm32 water lamp experiment_program interpretation
test.c includes 3 header files #include "stm32f10x_lib.h" some library functions of stm32 #include "sys.h" system clock initialization and some delay functions #include "led.h" running light related programs ================================================== ======================= First look at stm32f10x_lib.h It als
[Microcontroller]
STM32 unexpected reset problem debugging
I recently encountered a strange problem when using an STM32 project. The system ran normally at first, but after running for a long time, the STM2 microcontroller would randomly reset for no reason. Because I gained a lot during the debugging process, I plan to record this debugging process. First, let's analyze th
[Microcontroller]
STM32 unexpected reset problem debugging
STM32 port multiplexing & remapping
Let me tell you about the port remapping of the STM32 microcontroller, because I use myself as an example. Here I take the remapping of USART1 as an example. Because I want a TFT_LCD screen main control board, considering FSMC, I chose STM32F103VCT6 model CPU, and accidentally connected the serial port to USART1. Bec
[Microcontroller]
STM32 port multiplexing & remapping
stm32 SPI interface
1. Introduction to SPI  SPI is the abbreviation of Serial Peripheral interface. As the name implies, it is a serial peripheral device interface. It was first defined by Motorola on its MC68HCXX series processors. The SPI interface is mainly used in EEPROM, FLASH, real-time clock, AD converter, and between digital sign
[Microcontroller]
stm32 SPI interface
PID parameter definition based on MSP430 microcontroller
PID control is the most common control strategy. More than 90% of the control loops in industrial process control have PID structure. The reason why PID control is widely used is mainly because its algorithm is simple, easy to understand and implement in practice, and many advanced controls are based on PID control.
[Microcontroller]
PID parameter definition based on MSP430 microcontroller
Latest Medical Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号