Method and system for controlling synchronous movement of stepping motor set
Through the method of bilateral zero point calibration and timer collaborative control, the problems of low control efficiency and initialization accuracy of stepper motor units are solved, and efficient and accurate synchronous motion control is achieved.
Patent Information
- Application Number
- CN202311108747.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-02-28
AI Technical Summary
The existing stepper motor set control methods are inefficient and costly, and cannot achieve specific movements for a single stepper motor. The initialization setting accuracy is low and it is easily affected by barriers.
The bilateral zero point calibration method is used to initialize and set, and control instructions are generated through the upper timer, and the lower timer executes control instructions, and the movement of multiple stepper motors is controlled simultaneously through the SPI serial bus interface.
The operation efficiency and motion accuracy of the stepper motor set are improved, the cost is reduced, and efficient synchronous motion control of the stepper motor set is achieved.
Smart Images

Figure CN119543716A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of motor control, and in particular to a method and system for controlling a stepping motor group to perform synchronous motion. Background Art
[0002] The application of stepper motors is not unfamiliar in our lives. They can be found in mechanical equipment and household appliances. In some applications, the power of a single stepper motor is not enough to meet the use requirements, so a stepper motor group consisting of multiple stepper motors is required to run. For the control scheme of the stepper motor group, the commonly used method is single control, that is, one controller controls one stepper motor, or parallel control, one controller controls multiple stepper motors to move at the same time; or time-sharing control, one controller controls multiple stepper motors in turn. For the above control methods, the efficiency of single control is low, and multiple controllers need to be set up, which is costly; while for parallel control, multiple stepper motors under the control of one controller can only perform the same movement at the same time, and it is impossible to perform specific movements on a single stepper motor according to actual needs; time-sharing control is only suitable for scenarios where multiple stepper motors do not need to move at the same time. In addition, for the initialization setting of the stepper motor, a single-sided zero point calibration method is usually adopted, which has low accuracy. It may cause zero point calibration errors due to obstacles or other reasons, affecting the movement of the entire stepper motor. Summary of the invention
[0003] The purpose of the present invention is to overcome the shortcomings of the prior art. The present invention provides a method and system for controlling a stepper motor group to perform synchronous movement. The stepper motor group is initialized and set by a bilateral zero point calibration method, and an upper timer is used to generate control instructions and a lower timer is used to execute control instructions. The movement of multiple stepper motors is controlled simultaneously through an SPI serial bus interface, thereby improving the operating efficiency of the stepper motor group.
[0004] The present invention provides a method for controlling a stepping motor group to perform synchronous motion, the method comprising:
[0005] Acquire the initial position information of each stepper motor in the stepper motor group, and perform initialization setting on each stepper motor;
[0006] After the initialization setting is completed, updating and obtaining the target position information of each stepper motor;
[0007] The upper layer timer determines whether a stepper motor in the stepper motor group needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer;
[0008] The lower layer timer controls the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction.
[0009] Furthermore, the step of obtaining the initial position information of each stepper motor in the stepper motor group and initializing each stepper motor includes:
[0010] A sensor is arranged on the running track of the stepper motor group, and initial position information of each stepper motor in the stepper motor group is obtained based on the sensor;
[0011] Performing zero point calibration on the running track, and controlling each stepper motor to move in a direction opposite to the zero point until the stepper motor stops for the first time;
[0012] After the first stalling and stopping, the stepper motor is controlled to move toward the zero point until the second stalling and stopping occurs, and the number of steps of the stepper motor from the first stalling and stopping to the second stalling and stopping is recorded as the actual number of steps;
[0013] The actual number of steps is compared with the theoretical number of steps, and based on the comparison result, it is determined whether the initialization setting of the stepping motor is completed.
[0014] Further, after the initialization setting is completed, updating and obtaining the target position information of each stepper motor includes:
[0015] The target position information of each stepper motor in the stepper motor group is input based on the control terminal, and the target position information is transmitted to the upper timer.
[0016] Furthermore, if the initialization setting is not completed, the stepper motor that has not completed the initialization setting will not update the target position information, and upload the error information to the control terminal.
[0017] Further, the upper layer timer determines whether there is a stepper motor in the stepper motor group that needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer before including:
[0018] If the stepper motor is in motion, the target position information of the moving stepper motor is extracted and temporarily stored.
[0019] Further, the upper layer timer determines whether a stepper motor in the stepper motor group needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer, including:
[0020] The upper timer compares the initial position information and target position information corresponding to each stepper motor in the stepper motor group. If the initial position information and target position information corresponding to the stepper motor in the stepper motor group are inconsistent, the upper timer generates a motion control instruction and sends the motion control instruction to the lower timer.
[0021] Further, the upper layer timer generates a motion control instruction including:
[0022] The upper timer generates the motion parameters of the stepper motor according to the difference between the initial position information and the target position information. The motion parameters include the direction, angle and distance of the required movement, and packages the number of the stepper motor and the corresponding motion parameters to generate motion control instructions.
[0023] Furthermore, the lower layer timer controls the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction, including:
[0024] The lower layer timer formulates an overall motion plan for all the stepper motors in the stepper motor group based on the control instruction, and performs synchronous motion on the stepper motors that need to move in the stepper motor group based on the overall motion plan.
[0025] Furthermore, the controlling all the stepper motors that need to move to move based on the control instruction simultaneously includes:
[0026] The lower-level timer connects all the stepper motors that need to move through the SPI serial bus interface, and sends corresponding control instructions to different stepper motors at the same time by switching the level signal of the chip select pin of the SPI serial bus interface, thereby controlling all the stepper motors that need to move to move.
[0027] The present invention also provides a system for controlling a stepping motor group to perform synchronous motion, the system comprising:
[0028] An initialization setting module, the initialization setting module is used to obtain the initial position information of each stepper motor in the stepper motor group and perform initialization setting on each stepper motor;
[0029] A target position information acquisition module, wherein the target position information acquisition module is used to update and acquire the target position information of each stepping motor after the initialization setting is completed;
[0030] A control instruction generation module, wherein the control instruction generation module is used for the upper layer timer to determine whether there is a stepper motor in the stepper motor group that needs to move based on the initial position information and the target position information, generate a control instruction, and send the control instruction to the lower layer timer;
[0031] A control instruction execution module is used for the lower-level timer to control the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction.
[0032] The present invention performs initialization settings on each stepper motor in a stepper motor group, which can improve the accuracy of the stepper motor movement; an upper-layer timer is used to determine whether there is a stepper motor in the stepper motor group that needs to move, and a control instruction is generated and sent to a lower-layer timer. The lower-layer timer controls the movement of the stepper motor group according to the control instruction. The upper-layer timer only needs to send instructions to the lower-layer timer, and the lower-layer timer completes the control of the stepper motor movement. The two timers are used to realize simultaneous control of all stepper motors in the stepper motor group, which has low cost and high efficiency, and improves the operating efficiency of the stepper motor group. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0034] Figure 1 is a flow chart of a method for controlling a stepping motor group to perform synchronous motion in Embodiment 1 of the present invention;
[0035] Figure 2 is a flow chart of initializing and setting a stepping motor in the first embodiment of the present invention;
[0036] Figure 3 It is a system structure diagram for controlling a stepper motor group to perform synchronous motion in the second embodiment of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] In the present invention, it should be understood that terms such as "include" or "have" are intended to indicate the existence of features, numbers, steps, behaviors, components, parts or a combination thereof disclosed in the specification, and are not intended to exclude the possibility that one or more other features, numbers, steps, behaviors, components, parts or a combination thereof exist or are added.
[0039] It should also be noted that, in the absence of conflict, the embodiments and features of the embodiments of the present invention can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0040] Embodiment 1
[0041] Embodiment 1 of the present invention relates to a method for controlling a stepper motor group to perform synchronous movement, the method comprising: obtaining initial position information of each stepper motor in the stepper motor group, and initializing each stepper motor; after the initialization setting is completed, updating and obtaining target position information of each stepper motor; an upper-layer timer determines whether there is a stepper motor in the stepper motor group that needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to a lower-layer timer; the lower-layer timer controls the stepper motors that need to move in the stepper motor group to perform synchronous movement based on the control instruction.
[0042] In an optional implementation of this embodiment, Figure 1 As shown, Figure 1 A flow chart of a method for controlling a stepper motor group to perform synchronous motion in Embodiment 1 of the present invention is shown, comprising the following steps:
[0043] S101, obtaining initial position information of each stepper motor in the stepper motor group, and performing initialization setting on each stepper motor;
[0044] In an optional implementation of this embodiment, each stepper motor in the stepper motor group is initialized and set by an electronic control unit (ECU).
[0045] In an optional implementation of this embodiment, Figure 2 As shown, Figure 2 A flow chart of initializing a stepper motor in a first embodiment of the present invention is shown, comprising the following steps:
[0046] S201, setting a sensor on the running track of the stepper motor group, and obtaining initial position information of each stepper motor in the stepper motor group based on the sensor;
[0047] In an optional implementation of this embodiment, the initial position information of each stepper motor in the stepper motor group is acquired based on a laser sensor, an ultrasonic sensor or a millimeter wave sensor, and the initial position information of each stepper motor is calibrated in a spatial rectangular coordinate system.
[0048] It should be noted that the number of sensors set is not less than three, and the number of sensors in the X-axis, Y-axis, and Z-axis directions is not less than one.
[0049] In an optional implementation of this embodiment, the sensor obtains the initial position information of each stepper motor in the stepper motor group, and sends the initial position information to an upper-layer timer.
[0050] S202, performing zero point calibration on the running track, and controlling each stepper motor to move in a direction opposite to the zero point until the stepper motor stops for the first time;
[0051] In an optional implementation of this embodiment, a spatial point is selected as the zero point on the spatial rectangular coordinate system, and a line is connected between the point corresponding to the initial position information of the stepper motor on the spatial rectangular coordinate system and the zero point, and the motor is moved along the line in a direction away from the zero point until the stepper motor moves to the maximum direction and stops for the first time.
[0052] In an optional implementation of this embodiment, a Hall sensor may be used to detect whether the stepper motor is stalled.
[0053] Specifically, the Hall sensor is a magnetic field sensor made according to the Hall effect, which converts the changing magnetic field into the change of output voltage, can measure the physical quantity that generates and affects the magnetic field, and is commonly used in proximity switches, Hall, position measurement, speed measurement and current measurement equipment. In this embodiment, it can be used to detect the speed of the stepper motor, and then determine whether the stepper motor is blocked and stopped.
[0054] Specifically, in the rotor of the stepper motor, there is at least one pair of magnetic poles, including an N pole and an S pole, which are arranged adjacent to each other, and the N poles of the multiple pairs of magnetic poles are arranged at intervals, and the S poles are arranged at intervals. When the stepper motor is in motion and the rotor is rotating, when the Hall sensor is close to the rotor of the stepper motor, it senses the magnetic poles close to it and generates a corresponding feedback signal, which is called a Hall signal. When the stepper motor is moving, the rotor runs at a certain speed, and the magnetic poles sensed by the Hall sensor will change alternately, that is, the level of the generated Hall signal will change alternately accordingly. When the stepper motor stops moving, the level of the Hall signal generated by the Hall sensor will not change, and it can be determined that the stepper motor is stalled and stopped.
[0055] Here, a Hall sensor is used to monitor whether the stepper motor is stalled or not, which has high accuracy.
[0056] S203, controlling the stepper motor to move towards the zero point after the first stalling and stopping, until the stepper motor stalls and stops for the second time, and recording the number of steps the stepper motor moves from the first stalling and stopping to the second stalling and stopping as the actual number of steps;
[0057] In an optional implementation of this embodiment, after the stepper motor stops stalling for the first time, it moves toward the zero point and starts recording the number of movement steps until the Hall sensor detects that the stepper motor stops stalling for the second time, and this number of steps is recorded as the actual number of steps.
[0058] In an optional implementation of the present embodiment, it is possible to first determine the movement space of the stepper motor between the first stall stop and the second stall stop, such as 60°, and then define the conversion unit according to the model of the stepper motor. For example, 1° is 100 steps, then 60° corresponds to the stepper motor movement of 60*100=6000 steps, and so on.
[0059] S204: Compare the actual number of steps with the theoretical number of steps, and determine whether the initialization setting of the stepper motor is completed based on the comparison result.
[0060] In an optional implementation method of the present embodiment, the model of the stepper motor and the corresponding design scheme are obtained, the theoretical number of steps of the stepper motor is obtained, and the theoretical number of steps is compared with the actual number of steps. If the actual number of steps is less than the theoretical number of steps, it is determined that the initialization setting of the stepper motor is not completed. At this time, it is necessary to determine the reason for the incompleteness, whether there are obstacles on the running track of the stepper motor, resulting in inaccurate zero point calibration, resulting in failure of the initialization setting of the stepper motor.
[0061] It should be noted that the same initialization settings need to be made for each stepper motor in the stepper motor group.
[0062] S102, after the initialization setting is completed, updating and obtaining the target position information of each stepping motor;
[0063] In an optional implementation of this embodiment, if in step S204, it is determined that the stepper motor initialization setting is successful, the target position information of each stepper motor in the stepper motor group is input into the control terminal, and the target position information is transmitted to the upper timer.
[0064] Specifically, the target position information corresponding to each stepper motor is calibrated in a spatial rectangular coordinate system.
[0065] In an optional implementation of this embodiment, if it is determined in step S204 that the initialization setting of the stepper motor fails, the stepper motor that has not completed the initialization setting will not update the target position information, and the error information will be uploaded to the control terminal.
[0066] In an optional implementation of this embodiment, the stepper motor that has not completed the initialization setting cannot be controlled to move subsequently.
[0067] In an optional implementation of the present embodiment, after the error message of the stepper motor that has not completed the initialization setting is uploaded to the control terminal, subsequent operations can be performed only after the electronic control unit ECU successfully re-initializes the setting after power is turned off and on again or after waking up from sleep mode.
[0068] S103, the upper layer timer determines whether there is a stepper motor in the stepper motor group that needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer;
[0069] In an optional implementation of the present embodiment, before the upper-level timer determines whether there is a stepper motor in the stepper motor group that needs to move, generates a control instruction, and sends the control instruction to the lower-level timer, if the stepper motor is moving, the target position information of the moving stepper motor is extracted and temporarily stored.
[0070] Specifically, when the stepper motor is idle, the stepper motor moves according to the real-time position information and the target position information of the stepper motor at this time.
[0071] In an optional implementation of the present embodiment, the upper-level timer compares the initial position information and the target position information corresponding to each stepper motor in the stepper motor group. If the initial position information and the target position information corresponding to the stepper motor in the stepper motor group are inconsistent, the upper-level timer generates a motion control instruction and sends the motion control instruction to the lower-level timer.
[0072] Specifically, the upper timer generates the motion parameters of the stepper motor according to the difference between the initial position information and the target position information, wherein the motion parameters include the direction, angle, and distance required to move, and packages the number of the stepper motor and the corresponding motion parameters to generate motion control instructions.
[0073] Specifically, the motion parameters and serial numbers of the stepper motor may be expressed in units such as numbers and bytes.
[0074] In an optional implementation of this embodiment, if the initial position information and the target position information corresponding to the stepper motor in the stepper motor group are consistent, the stepper motor is set to an idle state.
[0075] In an optional implementation of this embodiment, when all the stepper motors that need to move have generated corresponding motion control instructions and sent them to the lower-layer timer, the upper-layer timer enters an idle state.
[0076] S104. The lower layer timer controls the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction.
[0077] In an optional implementation of this embodiment, the lower layer timer receives the control instruction sent by the upper layer timer, and controls all the stepper motors that need to move to move simultaneously based on the control instruction.
[0078] In an optional implementation of this embodiment, the lower-level timer formulates an overall motion plan for all stepper motors in the stepper motor group based on the control instruction, and synchronizes the stepper motors that need to move in the stepper motor group based on the overall motion plan.
[0079] Specifically, the lower-level timer formulates an overall motion plan for the stepper motor group according to the motion control instructions of all the stepper motors in the stepper motor group, avoiding collisions among all the stepper motors during movement, errors in the execution of motion control instructions, etc., and ensuring the normal synchronous movement of all the stepper motors in the stepper motor group.
[0080] In an optional implementation of this embodiment, the lower-level timer connects all the stepper motors that need to move through the SPI serial bus interface, and sends corresponding control instructions to different stepper motors at the same time by switching the level signal of the chip select pin of the SPI serial bus interface, thereby controlling all the stepper motors that need to move to move.
[0081] Specifically, according to the formulated overall motion plan, the lower-level timer sends SPI commands through the SPI serial bus interface, numbers different stepper motors, and sets the corresponding chip select CS pin level signal. When the corresponding stepper motor needs to be motion controlled, the lower-level timer sends the corresponding pin level signal by continuously switching the chip select CS pin of the SPI serial bus interface, and sends motion control instructions to the corresponding stepper motor, including motion direction, angle, distance, and motion speed, and at the same time controls all stepper motors that need to move to move.
[0082] In an optional implementation of this embodiment, when all the stepper motors that need to move move to the corresponding target positions, the lower layer timer enters an idle state.
[0083] In an optional implementation of the present embodiment, after all stepper motors in the stepper motor group have run to the corresponding target positions, the position information of all stepper motors in the stepper motor group at this time is obtained by a laser sensor, an ultrasonic sensor or a millimeter wave sensor to determine whether it is consistent with the preset target position information and perform accuracy assessment.
[0084] In summary, embodiment 1 of the present invention provides a method for controlling a stepper motor group to perform synchronous motion, and uses a bilateral zero point calibration method to initialize and set each stepper motor in the stepper motor group, so as to detect whether there are obstacles within the motion range of the stepper motor, ensure the safety of the motion, accurately calibrate the zero point, and improve the accuracy of the stepper motor motion; a sensor is used to sense the initial position information of the stepper motor, and the sensing accuracy is high and the speed is fast; an upper-level timer is used to generate the motion direction, angle, and distance of the stepper motor, and a control instruction is generated in combination with the number of the corresponding stepper motor, and the lower-level timer controls the motion of the stepper motor based on the control instruction. The upper-level timer only needs to send instructions to the lower-level timer, and the lower-level timer completes the control of the stepper motor motion. The two timers are used to realize simultaneous control of all stepper motors in the stepper motor group, with low cost and high efficiency; the lower-level timer realizes separate and simultaneous motion control of different stepper motors by switching the level signal of the chip select CS pin of the SPI serial bus interface, thereby improving the operating efficiency of the stepper motor group.
[0085] Embodiment 2
[0086] Embodiment 2 of the present invention provides a system for controlling a stepper motor group to perform synchronous motion, such as Figure 3 As shown, Figure 3 The structure diagram of the system for controlling the stepping motor group to perform synchronous motion in the second embodiment of the present invention is shown, and the system includes:
[0087] An initialization setting module 10, the initialization setting module 10 is used to obtain the initial position information of each stepper motor in the stepper motor group and perform initialization setting on each stepper motor;
[0088] In an optional implementation of the present embodiment, a sensor is set on the running track of the stepper motor group, and the initial position information of each stepper motor in the stepper motor group is obtained based on the sensor; zero point calibration is performed on the running track, and each stepper motor is controlled to move in the direction opposite to the zero point until the stepper motor stops for the first time; the stepper motor is controlled to move in the direction of the zero point after the first stop until the stepper motor stops for the second time, and the number of steps moved by the stepper motor from the first stop to the second stop is recorded as the actual number of steps; the actual number of steps is compared with the theoretical number of steps, and based on the comparison result, it is determined whether the initialization setting of the stepper motor is completed.
[0089] A target position information acquisition module 20, wherein the target position information acquisition module 20 is used to update and acquire the target position information of each stepping motor after the initialization setting is completed;
[0090] In an optional implementation of this embodiment, if it is determined that the initialization setting of the stepper motor is successful, the operator inputs the target position information of each stepper motor in the stepper motor group in the control terminal, and transmits the target position information to the upper timer.
[0091] In an optional implementation of this embodiment, if it is determined that the initialization setting of the stepper motor fails, the stepper motor that has not completed the initialization setting will not update the target position information, and the error information will be uploaded to the control terminal.
[0092] A control instruction generating module 30, wherein the control instruction generating module 30 is used for the upper layer timer to determine whether there is a stepper motor in the stepper motor group that needs to move based on the initial position information and the target position information, generate a control instruction, and send the control instruction to the lower layer timer;
[0093] In an optional implementation of the present embodiment, before the upper-level timer determines whether there is a stepper motor in the stepper motor group that needs to move, generates a control instruction, and sends the control instruction to the lower-level timer, if the stepper motor is moving, the target position information of the moving stepper motor is extracted and temporarily stored.
[0094] In an optional implementation of the present embodiment, the upper-level timer compares the initial position information and the target position information corresponding to each stepper motor in the stepper motor group. If the initial position information and the target position information corresponding to the stepper motor in the stepper motor group are inconsistent, the upper-level timer generates a motion control instruction and sends the motion control instruction to the lower-level timer.
[0095] Specifically, the upper timer generates the motion parameters of the stepper motor according to the difference between the initial position information and the target position information, wherein the motion parameters include the direction, angle, and distance required to move, and packages the number of the stepper motor and the corresponding motion parameters to generate motion control instructions.
[0096] The control instruction execution module 40 is used for the lower layer timer to control the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction.
[0097] In an optional implementation of this embodiment, the lower layer timer receives the control instruction sent by the upper layer timer, and controls all the stepper motors that need to move to move simultaneously based on the control instruction.
[0098] In an optional implementation of this embodiment, the lower-level timer formulates an overall motion plan for all stepper motors in the stepper motor group based on the control instruction, and synchronizes the stepper motors that need to move in the stepper motor group based on the overall motion plan.
[0099] Specifically, the lower-level timer formulates an overall motion plan for the stepper motor group according to the motion control instructions of all the stepper motors in the stepper motor group, avoiding collisions among all the stepper motors during movement, errors in the execution of motion control instructions, etc., and ensuring the normal synchronous movement of all the stepper motors in the stepper motor group.
[0100] In an optional implementation of the present embodiment, the lower-level timer is connected to all the stepper motors that need to move through the SPI serial bus interface, and sends corresponding control instructions to different stepper motors at the same time by switching the level signal of the chip select CS pin of the SPI serial bus interface, thereby controlling all the stepper motors that need to move to move.
[0101] In summary, the second embodiment of the present invention provides a system for controlling a stepper motor group to perform synchronous motion, which is used to execute a method for controlling a stepper motor group to perform synchronous motion in the first embodiment. The bilateral zero point calibration method is used to initialize and set each stepper motor in the stepper motor group, and whether there are obstacles within the motion range of the stepper motor can be detected to ensure the safety of the motion while accurately calibrating the zero point to improve the accuracy of the stepper motor motion; a sensor is used to sense the initial position information of the stepper motor, and the sensing accuracy is high and the speed is fast; an upper-layer timer is used to generate the motion direction, angle, and distance of the stepper motor, and a control instruction is generated in combination with the number of the corresponding stepper motor. The lower-layer timer controls the motion of the stepper motor based on the control instruction. The upper-layer timer only needs to send instructions to the lower-layer timer, and the lower-layer timer completes the control of the stepper motor motion. The two timers are used to realize the simultaneous control of all stepper motors in the stepper motor group, which is low in cost and high in efficiency; the lower-layer timer realizes the separate and simultaneous motion control of different stepper motors by switching the level signal of the chip select CS pin of the SPI serial bus interface, thereby improving the operating efficiency of the stepper motor group.
[0102] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0103] In addition, the embodiments of the present invention are described in detail above. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for controlling a stepper motor group to perform synchronous motion, characterized in that: The method comprises: Acquire the initial position information of each stepper motor in the stepper motor group, and perform initialization setting on each stepper motor; After the initialization setting is completed, updating and obtaining the target position information of each stepper motor; The upper layer timer determines whether a stepper motor in the stepper motor group needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer; The lower layer timer controls the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction.
2. The method for controlling a stepper motor group to perform synchronous motion according to claim 1, characterized in that: The step of obtaining the initial position information of each stepper motor in the stepper motor group and initializing each stepper motor comprises: A sensor is arranged on the running track of the stepper motor group, and initial position information of each stepper motor in the stepper motor group is obtained based on the sensor; Performing zero point calibration on the running track, and controlling each stepper motor to move in a direction opposite to the zero point until the stepper motor stops for the first time; After the first stalling and stopping, the stepper motor is controlled to move toward the zero point until the second stalling and stopping occurs, and the number of steps of the stepper motor from the first stalling and stopping to the second stalling and stopping is recorded as the actual number of steps; The actual number of steps is compared with the theoretical number of steps, and based on the comparison result, it is determined whether the initialization setting of the stepping motor is completed.
3. The method for controlling a stepper motor group to perform synchronous motion as claimed in claim 2, characterized in that: After the initialization setting is completed, updating and obtaining the target position information of each stepper motor includes: The target position information of each stepper motor in the stepper motor group is input based on the control terminal, and the target position information is transmitted to the upper timer.
4. The method for controlling a stepper motor group to perform synchronous motion as claimed in claim 3, characterized in that: If the initialization setting is not completed, the stepper motor that has not completed the initialization setting will not update the target position information, and upload the error information to the control terminal.
5. The method for controlling a stepper motor group to perform synchronous motion according to claim 1, characterized in that: The upper layer timer determines whether a stepper motor in the stepper motor group needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer before the upper layer timer comprises: If the stepper motor is in motion, the target position information of the moving stepper motor is extracted and temporarily stored.
6. The method for controlling a stepper motor group to perform synchronous motion as claimed in claim 5, characterized in that: The upper layer timer determines whether a stepper motor in the stepper motor group needs to move based on the initial position information and the target position information, generates a control instruction, and sends the control instruction to the lower layer timer, including: The upper timer compares the initial position information and target position information corresponding to each stepper motor in the stepper motor group. If the initial position information and target position information corresponding to the stepper motor in the stepper motor group are inconsistent, the upper timer generates a motion control instruction and sends the motion control instruction to the lower timer.
7. The method for controlling a stepper motor group to perform synchronous motion as claimed in claim 6, characterized in that: The upper layer timer generates a motion control instruction including: The upper timer generates the motion parameters of the stepper motor according to the difference between the initial position information and the target position information. The motion parameters include the direction, angle and distance of the required movement, and packages the number of the stepper motor and the corresponding motion parameters to generate motion control instructions.
8. The method for controlling a stepper motor group to perform synchronous motion according to claim 1, characterized in that: The lower layer timer controls the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction, including: The lower layer timer formulates an overall motion plan for all the stepper motors in the stepper motor group based on the control instruction, and performs synchronous motion on the stepper motors that need to move in the stepper motor group based on the overall motion plan.
9. The method for controlling a stepper motor group to perform synchronous motion as claimed in claim 8, characterized in that: The step of controlling all the stepper motors that need to move to move based on the control instruction simultaneously includes: The lower-level timer connects all the stepper motors that need to move through the SPI serial bus interface, and sends corresponding control instructions to different stepper motors at the same time by switching the level signal of the chip select pin of the SPI serial bus interface, thereby controlling all the stepper motors that need to move to move.
10. A system for controlling a stepper motor group to perform synchronous motion, characterized in that: The system comprises: An initialization setting module, the initialization setting module is used to obtain the initial position information of each stepper motor in the stepper motor group and perform initialization setting on each stepper motor; A target position information acquisition module, wherein the target position information acquisition module is used to update and acquire the target position information of each stepping motor after the initialization setting is completed; A control instruction generation module, wherein the control instruction generation module is used for the upper layer timer to determine whether there is a stepper motor in the stepper motor group that needs to move based on the initial position information and the target position information, generate a control instruction, and send the control instruction to the lower layer timer; A control instruction execution module is used for the lower-level timer to control the stepper motors that need to move in the stepper motor group to move synchronously based on the control instruction.