Six-axis driving system and driving method based on EtherCAT and CAN
Through the EtherCAT and CAN protocol combined with modular drivers and power-on adaptive configuration, the flexible combination of multi-axis motor servo drivers is achieved, which solves the problem of combining different power segments and axes, improves the stability and reliability of the system, and passes the Genetic algorithm optimizes PID parameters, improving control accuracy and efficiency.
Patent Information
- Application Number
- CN202410960631.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-11-08
AI Technical Summary
Existing multi-axis motor servo drives are difficult to achieve a flexible combination of different power segments and shaft numbers, which limits the flexibility of product production management.
The six-axis drive system based on EtherCAT and CAN is adopted, and the modular driver design and power-on adaptive configuration can achieve a flexible combination of different power segments and axes, and strengthen the stability and reliability of the system at the hardware and software level.
Improve the system's fault tolerance, start-up stability and reliability, ensure the sequential start-up and voltage control of the motor drive module, enhance communication reliability and safety, optimize PID parameters through genetic algorithms, and improve the control accuracy and efficiency of the system. .
Smart Images

Figure CN118920925A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent control technology, and in particular to a six-axis drive system and a drive method based on EtherCAT and CAN. Background Art
[0002] With the increasing requirements for control accuracy, processing efficiency, and intelligence, a single processing equipment requires more and more motor servo axes, so multi-axis servo motor drivers have emerged. However, in most practical applications, different numbers of servo motor axes are often required, and each axis is also a combination of different power ranges. Therefore, the application scope of multi-axis motor servo drivers is limited, and flexible combinations of different power ranges and numbers of axes cannot be achieved, which brings many inconveniences to product production management. Summary of the invention
[0003] The technical problem to be solved by the present invention is to provide a six-axis drive system and a drive method based on EtherCAT and CAN, so as to realize a flexible combination of different power segments and axis numbers of a multi-axis motor servo driver.
[0004] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0005] On the one hand, the present invention provides a six-axis drive system based on EtherCAT and CAN, comprising at least two modular drives, each of which comprises a main module, the main module is connected to a power module and three motor drive modules, and each module in each modular drive is equipped with a CPU chip, wherein:
[0006] The main modules of different modular drives communicate with each other using the EtherCAT protocol, and the modules in each modular drive communicate with each other using the CAN bus.
[0007] In each modular driver, each motor drive module is designed as a three-layer board hardware architecture, wherein the upper board is installed with the CPU chip, and the upper board is responsible for communicating with other modules and processing data, and the middle board and the lower board are both installed with motor drive chips, and the middle board and the lower board are responsible for motor drive, that is, one motor drive module controls two motors.
[0008] On the other hand, the present invention provides the above-mentioned driving method of the six-axis drive system based on EtherCAT and CAN. In each modular driver, the communication address of each motor drive module is set by a power-on adaptive configuration method, and the power-on adaptive configuration method is:
[0009] When the power module is powered on, the addresses of each module in each modular driver are set first. The default address of the power module is 0, the default address of the main module is 1, and the addresses of the remaining motor drive modules are automatically set to 2, 3, and 4 according to the connection relationship. Specifically, the power-on adaptive configuration method depends on the connection relationship of the hardware, and the connection relationship includes two aspects: First, in terms of hardware connection, the power module is the starting module, followed by the main module, motor drive module 1, motor drive module 2, and motor drive module 3. The modules are connected through POS-OUT and POS-IN pins; the POS-OUT represents the output pin of each module connected to the next module; the POS-IN represents the connection pin of each module to the previous module. The input pin of the module connection; the input pin and the output pin are used to mark whether the module is the module being configured; secondly, the modules are connected by CAN, and the data interaction of the adaptive configuration is performed through CAN communication; more specifically, the process of the power-on adaptive configuration method includes the following steps: step 1, first, considering that the main module is used to initialize the EtherCAT function when it is powered on, the module that triggers the configuration does not select the main module, but selects the idle power module, and the output pin of the main module is set to high by default, that is, the first motor drive module connected to the main module, namely, motor drive module 1, is configured by default; step 2, after power-on, the power module sends frame 1, and frame 1 is a data frame with a length of 0x04 and a frame format of "AA BB CC module address" start signal; at this time, other modules will receive frame 1, but each module will detect whether its own POS-IN is high and the address is 0. If POS-IN is high and the address is 0, the configuration address in the frame is extracted as the address of its own module, and a completion frame is returned; if POS-IN is low or POS-IN is high but the address is not 0, the module address in the frame is marked as not the address of its own module, so as to prevent the wrong configuration caused by repeated configuration of the same module when the non-self address but the POS_IN of the module itself is high; because the POS-OUT of the main module is high by default, the POS-IN of the motor driver module 1 is high by default, therefore, the motor driver module 1 is configured first; step 3, when the address configuration of the motor driver module 1 is completed, a completion frame will be returned, and the completion frame format is "CC BB AA module address", after the power module receives the completion frame, it stops configuring, otherwise, it configures once every 500ms; step 4, when the motor driver module 1 is configured, the motor driver module 1 is used as the trigger module for the next module configuration, and the configuration steps are similar to steps 2 and 3, and so on, until the address configuration of all motor driver modules is completed. After each motor driver module is configured, the motor is powered on and initialized. Therefore, the power-on timing of each motor driver module is powered on in sequence according to the timing of the serialized configuration, rather than synchronously.
[0010] The present invention has the following beneficial effects:
[0011] 1. Compared with the integrated motor drive system, the overall hardware architecture of the present invention has a modular hardware design, which makes it impossible for each function to encounter a large load problem during the operation and driving process, thereby improving the fault tolerance rate.
[0012] 2. The serialized startup method used in the power-on adaptive configuration method of the present invention, that is, starting each motor drive module in sequence, can effectively avoid power overload or startup shock, so that each module starts in sequence, thereby effectively ensuring the stability and reliability of the system during the startup process, and can effectively control the voltage state of the motor drive module during the startup process, thereby ensuring the stability and safety of the startup process; each motor drive module will send a feedback signal after the startup is completed, and the main module can confirm the status of each module based on these signals to ensure the normal operation of the system. This feedback mechanism helps to detect and handle faults in a timely manner and improve the reliability of the system.
[0013] 3. Genetic algorithms can find the optimal solution in the entire search space by simulating the process of biological evolution, so they have strong global optimization capabilities. Traditional PID parameter adjustment may be limited to local search or trial and error, while genetic algorithms can better avoid falling into local optimal solutions. Genetic algorithms can adaptively adjust search strategies during the search process, so that they can more effectively find the optimal solution in different problem scenarios. In contrast, traditional PID parameter adjustment may require manual adjustment and is not easy to adapt to different systems. For complex systems or systems with nonlinear characteristics, traditional PID algorithms may perform poorly; optimizing PID parameters through genetic algorithms can automatically optimize parameters, reduce the need for manual intervention, and improve the efficiency and accuracy of system adjustment, so as to better cope with this complexity and make the system control effect more stable and excellent.
[0014] 4. In real-time systems, the timeliness of communication is crucial. By adding an error detection mechanism to the CAN bus, errors in communication can be discovered and processed in a timely manner, thereby ensuring the real-time nature of communication; response error detection can detect errors in the message transmission process in a timely manner, including data loss and other issues, thereby improving the reliability of communication; CRC error detection can detect the integrity of the data packet, further improving the reliability of data transmission; response error detection and CRC error detection can effectively reduce the loss and damage during data transmission, ensure that data can be correctly transmitted and received in the expected manner, and improve the stability of the system; by timely detecting and correcting errors in communication, the impact of malicious attacks or accidents on the system can be prevented, thereby improving the security of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a schematic diagram of the structure of a single modular driver in the six-axis drive system based on EtherCAT and CAN of the present invention;
[0016] Figure 2 It is a schematic diagram of the principle of the driving method of the six-axis driving system based on EtherCAT and CAN of the present invention;
[0017] Figure 3 for Figure 2 A schematic diagram of the process flow of the genetic algorithm in the driving method shown;
[0018] Figure 4 It is a schematic diagram of the principle of the power-on adaptive configuration mode and its response error detection in the present invention. DETAILED DESCRIPTION
[0019] In order to make the technical problems, technical solutions and advantages to be solved by the present invention more clear, a detailed description will be given below with reference to the accompanying drawings and specific embodiments.
[0020] In the description of the present invention, it is necessary to understand that the directions or positional relationships indicated by the terms "up", "down", "front", "back", "left", "right", etc. are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as a limitation on the present invention.
[0021] On the one hand, the present invention provides a six-axis drive system based on EtherCAT and CAN, such as Figure 1 As shown, at least two modular drivers 1 are included, each modular driver 1 includes a main module 11, the main module 11 is connected to a power module 12 and three motor drive modules 13, 14, 15, and each module in each modular driver 1 is installed with a CPU chip, wherein:
[0022] The main modules 11 of different modular drives 1 communicate with each other using the EtherCAT protocol, and the modules in each modular drive 1 communicate with each other using the CAN bus;
[0023] In each modular driver 1, each motor drive module 13, 14, 15 is designed as a three-layer board hardware architecture, wherein the upper board is installed with the CPU chip, and the upper board is responsible for communicating and processing data with other modules, and the middle board and the lower board are both installed with motor drive chips, and the middle board and the lower board are responsible for motor drive, that is, one motor drive module controls two motors.
[0024] The six-axis drive system of the present invention is described in detail below.
[0025] 1. Overall hardware architecture
[0026] 1-1. Modularity
[0027] In the present invention, for the problem that the load capacity that occurs for integrated driver is large and error-prone to stop working and cause to affect production, it is selected that each function of driver is modularized, i.e., main module, power module and motor drive module, and CPU chip is installed in each module so as to effectively solve the problem of large load capacity. Preferably, the model of CPU chip can be STM32F407VET6, and the model of motor drive chip can be TMC5160. Wherein plug-in terminal (specifically can be XY2500V-D-5.08-6P) can be used to connect between each module.
[0028] 1-2. Motor drive module
[0029] Preferably, in each modular drive 1, three motor drive modules 13, 14, 15 can be connected in series and connected to the main module 11 to realize the six-axis motor drive of the drive system.
[0030] Figure 1 For the hardware design of the six-axis drive system based on EtherCAT and CAN of the present invention, each module CPU configuration of modular (servo) driver is STM32F4xx series chip such as STM32F407VET6, so that each functional module can operate independently. Wherein the motor drive module hardware design is a three-layer board, the upper plate communicates by carrying STM32F407VET6, and the middle plate and the lower plate are respectively equipped with TMC series chips such as TMC5160 for motor drive. Five modules are connected by XY2500V-D-5.08-6P interface, and the XY2500V-D-5.08-6P interface of the last module, i.e., the motor drive module, can also be connected to CANTest hardware, so as to observe the CAN data frame on the CAN bus in real time.
[0031] 2. Overall software architecture
[0032] 2-1. EtherCAT
[0033] A drive system contains multiple modular drives, and the main modules of different modular drives communicate with each other using the EtherCAT protocol.
[0034] EtherCAT protocol is a real-time Ethernet technology. EtherCAT data frame message consists of destination address (6 bytes), source address (6 bytes), data content is EtherCAT-specific 0X88A4 frame type (2 bytes), EtherCAT header (2 bytes), EtherCAT data (44-1498 bytes) and FCS (4 bytes). EtherCAT data contains countless sub-messages, and a sub-message consists of sub-message header (10 bytes), data (up to 1486 bytes) and WKC (2 bytes). The sub-message header is composed of command (8 bits), index (8 bits), address area (32 bits), length (11 bits), R (4 bits), M (1 bit) and status bit (16 bits). In the EtherCAT protocol, when the EtherCAT master sends an EtherCAT data frame to the EtherCAT slave, the destination address and address area of the data frame message preferably include different MAC addresses of different modular drive master modules. At the same time, different EtherCAT slaves (modular drives) will also send EtherCAT data frames to feed back their own status to the EtherCAT master.
[0035] 2-2. CAN
[0036] In the present invention, an EtherCAT slave station (modular driver) includes a master module, a power module and three motor drive modules, and the communication between the modules uses the CAN bus.
[0037] CAN bus is a local area network technology that can be used to connect different devices and allow them to exchange data with each other. It has the characteristics of low latency, low cost and high fault tolerance. According to the communication requirements between different modules in the modular drive, the corresponding CAN bus protocol file can be generated using SSC software.
[0038] In the present invention, in software design, data communication between different servo drivers and between the host end and the slave end follows the EtherCAT protocol; and the main module and the slave module of the servo driver and the slave modules are connected by the CAN bus, so the data communication between the main module and the slave module of the servo driver and the slave modules follows the CAN protocol. First, the host end will exchange data with different servo drivers for data frames containing motor drive parameters of different slave stations, and then the data frames will be transmitted to the CAN bus through the main module of the servo driver, and then communicate data with the slave module of the servo driver, that is, the motor drive module, to achieve control of the motor.
[0039] On the other hand, the present invention provides a driving method for the above-mentioned six-axis drive system based on EtherCAT and CAN, such as Figure 2-3 As shown, in each modular driver, the communication address of each motor drive module is set by power-on adaptive configuration.
[0040] 3. Automatic address allocation function
[0041] 3-1. Power-on adaptive configuration method
[0042] To solve the startup problem of multi-motor drive modules, select the power-on adaptive configuration mode. The power-on adaptive configuration mode is:
[0043] When the power module is powered on, the addresses of each module in each modular driver are set first. The default address of the power module is 0, the default address of the main module is 1, and the addresses of the remaining motor drive modules are automatically set to 2, 3, and 4 according to the connection relationship. Specifically, the power-on adaptive configuration method depends on the connection relationship of the hardware, and the connection relationship includes two aspects: First, in terms of hardware connection, the power module is the starting module, followed by the main module, motor drive module 1, motor drive module 2, and motor drive module 3. The modules are connected through POS-OUT and POS-IN pins; the POS-OUT represents the output pin of each module connected to the next module; the POS-IN represents the connection pin of each module to the previous module. The input pin of the module connection; the input pin and the output pin are used to mark whether the module is the module being configured; secondly, the modules are connected by CAN, and the data interaction of the adaptive configuration is performed through CAN communication; more specifically, the process of the power-on adaptive configuration method includes the following steps: step 1, first, considering that the main module is used to initialize the EtherCAT function when it is powered on, the module that triggers the configuration does not select the main module, but selects the idle power module, and the output pin of the main module is set to high by default, that is, the first motor drive module connected to the main module, namely, motor drive module 1, is configured by default; step 2, after power-on, the power module sends frame 1, and frame 1 is a data frame with a length of 0x04 and a frame format of "AA BB CC module address" start signal; at this time, other modules will receive frame 1, but each module will detect whether its own POS-IN is high and the address is 0. If POS-IN is high and the address is 0, the configuration address in the frame is extracted as the address of its own module, and a completion frame is returned; if POS-IN is low or POS-IN is high but the address is not 0, the module address in the frame is marked as not the address of its own module, so as to prevent the wrong configuration caused by repeated configuration of the same module when the non-self address but the POS_IN of the module itself is high; because the POS-OUT of the main module is high by default, the POS-IN of the motor driver module 1 is high by default, therefore, the motor driver module 1 is configured first; step 3, when the address configuration of the motor driver module 1 is completed, a completion frame will be returned, and the completion frame format is "CC BB AA module address", after the power module receives the completion frame, it stops configuring, otherwise, it configures once every 500ms; step 4, when the motor driver module 1 is configured, the motor driver module 1 is used as the trigger module for the next module configuration, and the configuration steps are similar to steps 2 and 3, and so on, until the address configuration of all motor driver modules is completed. After each motor driver module is configured, the motor is powered on and initialized. Therefore, the power-on timing of each motor driver module is powered on in sequence according to the timing of the serialized configuration, rather than synchronously.
[0044] 3-2. Power-on adaptive configuration mode response error detection
[0045] The CAN controller has complete error detection capabilities during CAN bus communication. The error detection used during CAN bus communication includes: bit error detection, format error detection, fill error detection, response error detection and / or CRC error detection.
[0046] During the startup of each motor drive module, three types of response error problems may occur. The first response error problem is that after the output voltage of the current module is set to a high level, the latter module is converted to a high level through the connection port between the two, and then the former module fails to receive the feedback signal of successful startup of the motor drive module sent by the latter module within the specified time period; the second response error problem is that during the process of the first module driving the second module, the output voltage of the second module may be mistakenly set to a high level, thereby mistakenly driving the third module; the third response error problem is that based on the second response error, the startup signal that the first module should have sent to the second module is accepted by the third module, thereby starting the third module.
[0047] Aiming at the problem that the starting modules of multiple motor drive modules cannot be started in sequence, the present invention constructs a response error detection method based on a power-on adaptive configuration mode.
[0048] To ensure that the motor drive module starts smoothly, preferably, the response error detection (method) includes:
[0049] When the motor starts, when the power module configures the address of the first motor driver module, the power module will send a start signal to the first motor driver module. The timing starts after the start signal is sent. If the power module still does not receive a feedback signal from the first motor driver module after a preset time (specifically 500ms), the main module resends the start signal.
[0050] In order to prevent the response error in the startup phase, that is, when the first motor driver module is successfully started and then the second motor driver module is started, the second motor driver module may mistakenly receive the start signal from the main module, resulting in the second motor driver module being assigned the same address as the first motor driver module. To address this problem, preferably, the response error detection is as follows Figure 4 Also includes:
[0051] During the module address configuration process, an array of size SLAVE_MODULE_NUM is pre-set in each motor driver module, recorded as RcvIdCnt[SLAVE_MODULE_NUM], where SLAVE_MODULE_NUM is the maximum number of slave stations, and the RcvIdCnt array is used to mark the ID of the received configuration frame of the non-self-module address; the configuration frame of the non-self-module address refers to the configuration frame received when the POS-IN of the module is low; the index of the RcvIdCnt array represents the motor driver module number, specifically, index 0 represents motor module 1, index 1 represents motor module 2, and so on; when the motor driver module receives the configuration frame, it first searches the RcvIdCnt array to see if the tag value of the corresponding motor driver module is 0. If it is 0, it means that the frame is the configuration frame of this module, otherwise, the corresponding RcvIdCnt array value is accumulated.
[0052] In addition to adding an RcvIdCnt[SLAVE_MODULE_NUM] array to achieve a method for acknowledging response errors between each module in the servo drive system slave station, in order to prevent response timeout errors, a detection and timeout retransmission function is added to the servo drive system, and the detection and timeout retransmission function includes:
[0053] During the address configuration process, the modular drive is configured in sequence. The module in the front sequence sends a start signal every 500ms, and stops sending only when it receives the corresponding feedback signal. Otherwise, the module in the front sequence will continue to send the start signal until it stops due to a timeout error. In addition to the reception detection of the feedback signal, the servo drive system also sends a start signal every 500ms in case of loss of the start signal, so as to ensure the smooth startup of the entire servo drive system.
[0054] 4. Return to zero function
[0055] In view of the motor zero return problem, the present invention preferably installs a photoelectric proximity switch on each motor, sets the photoelectric proximity switch as the origin of the motor zero return, and uses an adaptive PID control algorithm based on a genetic algorithm to optimize the motor zero return process. It is difficult to achieve accurate zero return of the servo motor by relying solely on a photoelectric proximity switch, that is, there will be a zero return deviation of 0 to 5 degrees. Therefore, an adaptive PID algorithm based on genetic algorithm optimization is introduced to achieve a more accurate zero return by adaptively adjusting the PID control parameters.
[0056] PID control algorithm is a commonly used control algorithm in industrial control. It achieves stable control of the system by continuously adjusting the proportional, integral and differential parts. PID control algorithm is also a classic control algorithm and is widely used in motor speed and position control. However, the traditional PID algorithm parameter adjustment method may not meet the control requirements of some specific systems. Therefore, it is necessary to introduce a more optimized adjustment method to improve the control performance and stability of the system. Genetic algorithm, as a heuristic search and optimization method, has global optimization capability and adaptability, and can effectively optimize the traditional PID control algorithm.
[0057] 4-1. Photoelectric proximity switch
[0058] Photoelectric proximity switch is a sensor that converts the change of light intensity between the transmitting end and the receiving end into the change of current to achieve the purpose of detection. Photoelectric proximity switch is composed of three parts: transmitter, receiver and detection circuit. The transmitter aims at the target to emit a light beam, which is generally derived from a light-emitting diode (LED) and a laser diode. The light beam is emitted continuously or the pulse width is changed. The radiation intensity of the pulse-modulated light beam is selected many times during the emission and runs directly toward the target. The receiver is composed of a photodiode or a phototransistor. In front of the receiver, optical elements such as lenses and apertures are installed. Behind it is the detection circuit, which can filter out the effective signal and apply the signal.
[0059] Install it on the motor. When the motor runs and scans the photoelectric proximity switch, the position is set as the origin of the motor's return to zero.
[0060] 4-2. PID algorithm
[0061] PID algorithm is a classic control algorithm that controls the controlled object by linearly combining the proportional, integral, and derivative of the deviation to form a control variable.
[0062] The general expression of the PID control algorithm transfer function is:
[0063]
[0064] in:
[0065] k p is the proportional gain;
[0066] k i is the integral gain;
[0067] k d is the differential gain.
[0068] Proportional: Adjust the system control quantity in proportion to the deviation to produce a control effect and reduce the deviation. The role of the proportional coefficient is to increase the speed of system response. The larger the proportional coefficient, the faster the system response, but the system is prone to overshoot. If the proportional coefficient is too small, it will affect the accuracy of system regulation, the system response time will be longer, and the dynamic response of the system will be worse.
[0069] Integration: It is used to eliminate static error and improve the system's degree of freedom from error. The integration time constant determines the strength of the integration link. However, if the integration effect is too strong, it will affect the stability of the system.
[0070] Differential: Adjust the system control quantity according to the changing trend of the deviation. Before the deviation signal changes significantly, introduce a correction signal in advance to speed up the system action and reduce the adjustment time. When adjusting the differential parameters, it is necessary to pay attention to the fact that too strong a differential effect may cause system oscillation.
[0071] 4-3. PID algorithm based on adaptive genetic algorithm (AGA)
[0072] Adaptive genetic algorithm (AGA) is an adaptive algorithm derived from a parallel random search optimal method genetic algorithm derived from the biological evolution law of "survival of the fittest" proposed by Holland to simulate nature. As a randomized search algorithm, it first generates a set of initial solutions, and operates the variables of the initial solutions through "copying", "crossover" and "mutation". Individuals with low fitness are eliminated through individual fitness indicators, so that the entire "population" develops in a direction that is more adapted to the environment, thereby obtaining the optimal solution. Theoretically, under the premise of retaining the best individuals of the previous generation, the genetic algorithm is globally convergent during the iteration process and has a strong global search capability.
[0073] As a heuristic search and optimization method, genetic algorithm has global optimization capability and adaptability, and can effectively optimize the parameters of PID control algorithm.
[0074] The crossover probability P c and mutation probability P m The formula is as follows:
[0075]
[0076] Where: f max is the maximum fitness value in the population;
[0077] f avg is the average fitness value of the population in each generation;
[0078] f ′ is the fitness value of the larger parent;
[0079] f is the fitness value of the two parents;
[0080] k1, k2, k3, k4 are adaptive control parameters, and their value range is a constant between (0, 1).
[0081] In the specific implementation, preferably, when designing a PID controller based on a genetic algorithm, it is first necessary to establish a suitable objective function, which usually includes indicators such as the system's response speed, overshoot, stability, etc., in order to evaluate the quality of the PID parameters. At the same time, the genetic algorithm involves the setting of parameters such as population size, crossover probability, and mutation probability. The selection of these parameters directly affects the algorithm's search ability and convergence speed. During the design process, it is necessary to make adjustments based on the specific needs of the servo motor in the application scenario (such as express logistics sorting) to ensure that the algorithm can effectively search for the optimal solution. In the genetic algorithm, the PID parameters need to be encoded and decoded. The PID parameters are usually represented by binary encoding, and the corresponding parameter values are obtained by decoding operations. The PID parameters are optimized and iterated by the genetic algorithm. The present invention performs optimization calculations and iterations on the three control parameters k in the PID. P , k i , k d The optimized PID parameters are generally real values, and binary encoding is used. Three 10-bit binary encoding substrings are used to represent the control parameters k and P , k i , k d , and then connect all the substrings into a complete chromosome, thus forming an individual in the genetic space. c , mutation probability P m According to the application scenario of the present invention, the selection ranges of these three key parameters are 20-30, 0.75-0.95, and 0.005-0.01, respectively, until the set termination condition is met.
[0082] In summary, the present invention has the following beneficial effects:
[0083] 1. Compared with the integrated motor drive system, the overall hardware architecture of the present invention has a modular hardware design, which makes it impossible for each function to encounter a large load problem during the operation and driving process, thereby improving the fault tolerance rate.
[0084] 2. The serialized startup method used in the power-on adaptive configuration method of the present invention, that is, starting each motor drive module in sequence, can effectively avoid power overload or startup shock, so that each module starts in sequence, thereby effectively ensuring the stability and reliability of the system during the startup process, and can effectively control the voltage state of the motor drive module during the startup process, thereby ensuring the stability and safety of the startup process; each motor drive module will send a feedback signal after the startup is completed, and the main module can confirm the status of each module based on these signals to ensure the normal operation of the system. This feedback mechanism helps to detect and handle faults in a timely manner and improve the reliability of the system.
[0085] 3. Genetic algorithms can find the optimal solution in the entire search space by simulating the process of biological evolution, so they have strong global optimization capabilities. Traditional PID parameter adjustment may be limited to local search or trial and error, while genetic algorithms can better avoid falling into local optimal solutions. Genetic algorithms can adaptively adjust search strategies during the search process, so that they can more effectively find the optimal solution in different problem scenarios. In contrast, traditional PID parameter adjustment may require manual adjustment and is not easy to adapt to different systems. For complex systems or systems with nonlinear characteristics, traditional PID algorithms may perform poorly; optimizing PID parameters through genetic algorithms can automatically optimize parameters, reduce the need for manual intervention, and improve the efficiency and accuracy of system adjustment, so as to better cope with this complexity and make the system control effect more stable and excellent.
[0086] 4. In real-time systems, the timeliness of communication is crucial. By adding an error detection mechanism to the CAN bus, errors in communication can be discovered and processed in a timely manner, thereby ensuring the real-time nature of communication; response error detection can detect errors in the message transmission process in a timely manner, including data loss and other issues, thereby improving the reliability of communication; CRC error detection can detect the integrity of the data packet, further improving the reliability of data transmission; response error detection and CRC error detection can effectively reduce the loss and damage during data transmission, ensure that data can be correctly transmitted and received in the expected manner, and improve the stability of the system; by timely detecting and correcting errors in communication, the impact of malicious attacks or accidents on the system can be prevented, thereby improving the security of the system.
[0087] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A six-axis drive system based on EtherCAT and CAN, characterized in that: It includes at least two modular drivers, each of which includes a main module connected to a power module and three motor drive modules. Each module in each modular driver is equipped with a CPU chip, wherein: The main modules of different modular drives communicate with each other using the EtherCAT protocol, and the modules in each modular drive communicate with each other using the CAN bus. In each modular driver, each motor drive module is designed as a three-layer board hardware architecture, wherein the upper board is installed with the CPU chip, and the upper board is responsible for communicating with other modules and processing data, and the middle board and the lower board are both installed with motor drive chips, and the middle board and the lower board are responsible for motor drive, that is, one motor drive module controls two motors.
2. The six-axis drive system based on EtherCAT and CAN according to claim 1, characterized in that: In each modular drive, the modules are connected using plug-in terminals; and / or, in the EtherCAT protocol, the destination address and address area of the data frame message contain different MAC addresses of the main modules of different modular drives; And / or, in each modular drive, three motor drive modules are connected in series and to a main module.
3. The six-axis drive system based on EtherCAT and CAN according to claim 1, characterized in that: The model of the CPU chip is STM32F4xx series; And / or, the motor driver chip is of TMC series.
4. The driving method of the six-axis drive system based on EtherCAT and CAN according to any one of claims 1 to 3, characterized in that: In each modular driver, the communication address of each motor drive module is set using a power-on adaptive configuration method, which is as follows: When the power module is powered on, the addresses of each module in each modular driver will be set first. The default address of the power module is 0, the default address of the main module is 1, and the addresses of the remaining motor drive modules are automatically set to 2, 3, and 4 according to the connection relationship. Specifically, the power-on adaptive configuration method depends on the connection relationship of the hardware, and the connection relationship includes two aspects: First, in terms of hardware connection, the power module is the starting module, followed by the main module, motor drive module 1, motor drive module 2, and motor drive module 3. The modules are connected through POS-OUT and POS-IN pins; POS-OUT represents the output pin of each module connected to the next module; POS-IN represents the pin of each module connected to the previous module. The input pin of the module connection; the input pin and the output pin are used to mark whether the module is the module being configured; secondly, the modules are connected by CAN, and the data interaction of the adaptive configuration is performed through CAN communication; more specifically, the process of the power-on adaptive configuration method includes the following steps: step 1, first, considering that the main module is used to initialize the EtherCAT function when it is powered on, the module that triggers the configuration does not select the main module, but selects the idle power module, and the output pin of the main module is set to high by default, that is, the first motor drive module connected to the main module, namely motor drive module 1, is configured by default; step 2, after power-on, the power module sends frame 1, and the frame 1 is a data frame with a length of 0x04 and a frame format of "AA BB CC module address" start signal; at this time, other modules will receive frame 1, but each module will detect whether its own POS-IN is high and the address is 0. If POS-IN is high and the address is 0, the configuration address in the frame will be extracted as the address of its own module, and a completion frame will be returned; if POS-IN is low or POS-IN is high but the address is not 0, the module address in the frame will be marked as not the address of its own module, so as to prevent the misconfiguration caused by repeated configuration of the same module when the non-self address is not the own address but the POS_IN of the module itself is high; because the POS-OUT of the main module is high by default, the POS-IN of the motor driver module 1 is high by default, therefore, the motor driver module 1 is configured first; step 3, when the address configuration of the motor driver module 1 is completed, a completion frame will be returned, and the completion frame format is "CC BB AA module address", after the power module receives the completion frame, it stops configuration, otherwise it configures once every 500ms; step 4, when the configuration of motor driver module 1 is completed, motor driver module 1 serves as the trigger module for the configuration of the next module. The configuration steps are similar to steps 2 and 3, and so on, until the address configuration of all motor driver modules is completed. After the configuration of each motor driver module is completed, the motor is powered on and initialized. Therefore, the power-on timing of each motor driver module is powered on in sequence according to the serial configuration timing, rather than synchronously.
5. The method according to claim 4, characterized in that During CAN bus communication, the error detection used includes: bit error detection, format error detection, padding error detection, response error detection and / or CRC error detection, wherein the response error detection includes: When the motor starts, when the power module configures the address of the first motor driver module, the power module will send a start signal to the first motor driver module. The timing starts after the start signal is sent. If the main module still does not receive the feedback signal from the first motor driver module after the preset time, the power module will resend the start signal.
6. The method according to claim 5, characterized in that The response error detection further includes: During the module address configuration process, an array of size SLAVE_MODULE_NUM is pre-set in each motor driver module, recorded as RcvIdCnt[SLAVE_MODULE_NUM], where SLAVE_MODULE_NUM is the maximum number of slave stations, and the RcvIdCnt array is used to mark the ID of the received configuration frame of the non-self-module address; the configuration frame of the non-self-module address refers to the configuration frame received when the POS-IN of the module is low; the index of the RcvIdCnt array represents the motor driver module number, specifically, index 0 represents motor module 1, index 1 represents motor module 2, and so on; when the motor driver module receives the configuration frame, it first searches the RcvIdCnt array to see if the tag value of the corresponding motor driver module is 0. If it is 0, it means that the frame is the configuration frame of this module, otherwise, the corresponding RcvIdCnt array value is accumulated.
7. The method according to claim 4, characterized in that The method also includes a detection and timeout retransmission function, wherein the detection and timeout retransmission function include: During the address configuration process, the modular drive is configured in sequence. The module in the front sends a start signal every 500ms and stops sending only when it receives the corresponding feedback signal. Otherwise, the module in the front will continue to send the start signal until it stops due to a timeout error.
8. The method according to claim 4, characterized in that Each motor is equipped with a photoelectric proximity switch, which is set as the origin of the motor's zero return. An adaptive PID control algorithm based on genetic algorithm is used to optimize the motor's zero return process.
9. The method according to claim 8, characterized in that In the process of optimizing the motor return to zero using the PID control algorithm based on the adaptive genetic algorithm, when designing the PID controller based on the genetic algorithm, it is necessary to establish a suitable objective function, which includes the response speed, overshoot, and stability index of the system, in order to evaluate the quality of the PID parameters; in the genetic algorithm, the PID parameters need to be encoded and decoded, and the PID parameters are represented by binary coding, and the corresponding parameter values are obtained through decoding operations; the PID parameters are optimized and iterated by the genetic algorithm, in which the three control parameters k in the PID are P 、k i 、k d Perform tuning optimization.
10. The method according to claim 9, characterized in that The adaptive PID control algorithm based on genetic algorithm is used to optimize the motor return to zero process. The optimized PID parameters are real values. Binary encoding is used, and three 10-bit binary encoding substrings are used to represent the control parameters k. P 、k i 、k d , and then connect all the substrings into a complete chromosome, thus forming an individual in the genetic space; for the population size n and crossover probability P of the genetic algorithm c , mutation probability P m These three key parameters are selected in the range of 20-30, 0.75-0.95, and 0.005-0.01, respectively, according to the application scenario, until the set termination conditions are met.
