CN110601605A - Method, device and system for controlling motor - Google Patents

Method, device and system for controlling motor Download PDF

Info

Publication number
CN110601605A
CN110601605A CN201910746130.2A CN201910746130A CN110601605A CN 110601605 A CN110601605 A CN 110601605A CN 201910746130 A CN201910746130 A CN 201910746130A CN 110601605 A CN110601605 A CN 110601605A
Authority
CN
China
Prior art keywords
pulse
mcu
rotary encoder
motor
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910746130.2A
Other languages
Chinese (zh)
Inventor
王智玮
王聪
李龙剑
杨庆庆
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SUZHOU FURUISI INFORMATION TECHNOLOGY Co.,Ltd.
Beijing Zhaoyi Innovation Technology Co Ltd
Hefei Geyi Integrated Circuit Co Ltd
Original Assignee
GigaDevice Semiconductor Beijing Inc
Hefei Geyi Integrated Circuit Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by GigaDevice Semiconductor Beijing Inc, Hefei Geyi Integrated Circuit Co Ltd filed Critical GigaDevice Semiconductor Beijing Inc
Priority to CN201910746130.2A priority Critical patent/CN110601605A/en
Publication of CN110601605A publication Critical patent/CN110601605A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H02GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
    • H02PCONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
    • H02P6/00Arrangements for controlling synchronous motors or other dynamo-electric motors using electronic commutation dependent on the rotor position; Electronic commutators therefor
    • H02P6/08Arrangements for controlling the speed or torque of a single motor
    • HELECTRICITY
    • H02GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
    • H02PCONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
    • H02P6/00Arrangements for controlling synchronous motors or other dynamo-electric motors using electronic commutation dependent on the rotor position; Electronic commutators therefor
    • H02P6/14Electronic commutators
    • H02P6/16Circuit arrangements for detecting position
    • HELECTRICITY
    • H02GENERATION; CONVERSION OR DISTRIBUTION OF ELECTRIC POWER
    • H02PCONTROL OR REGULATION OF ELECTRIC MOTORS, ELECTRIC GENERATORS OR DYNAMO-ELECTRIC CONVERTERS; CONTROLLING TRANSFORMERS, REACTORS OR CHOKE COILS
    • H02P6/00Arrangements for controlling synchronous motors or other dynamo-electric motors using electronic commutation dependent on the rotor position; Electronic commutators therefor
    • H02P6/34Modelling or simulation for control purposes

Landscapes

  • Engineering & Computer Science (AREA)
  • Power Engineering (AREA)
  • Control Of Motors That Do Not Use Commutators (AREA)

Abstract

The invention provides a method and a system for controlling a motor, and relates to the field of electronics. The method comprises the following steps: and obtaining a preset pulse value stored by the MCU, counting the pulse value generated by the rotary encoder, comparing whether the currently counted pulse value is equal to the preset pulse value, and obtaining a next preset pulse value stored by the MCU under the condition that the currently counted pulse value is equal to the preset pulse value, wherein an interrupt signal is used for enabling the MCU to carry out phase change operation on the motor. The method and the system for controlling the motor do not need to change the existing circuit structure and the structure of each device in the using process, are simple, convenient and high in accuracy, can be adjusted adaptively according to the specific performance of the rotary encoder, and have the advantages of clear and concise whole method, strong operability and wider application range.

Description

Method, device and system for controlling motor
Technical Field
The invention relates to the field of electronics, in particular to a method, a device and a system for controlling a motor.
Background
The brushless direct current motor is composed of a motor main body and a driver, and is a typical electromechanical integration product. The brushless motor is a motor without a brush and a commutator (or a collecting ring), which is also called a commutator-free motor, and when the motor is produced in nineteenth ages, the produced practical motor is in a brushless form, namely an alternating current squirrel cage type asynchronous motor, and the motor is widely applied. However, asynchronous motors have a number of insurmountable drawbacks, which have led to slow motor technology development. The transistor is produced in the middle of the last century, so that a direct current brushless motor adopting a transistor commutation circuit to replace an electric brush and a commutator is produced, the novel brushless motor is called an electronic commutation type direct current motor, and the defects of the first generation brushless motor are overcome.
At present, a brushless direct current motor widely applied is a three-phase brushless direct current motor, the rotating speed and the steering of the three-phase brushless direct current motor are controlled to generally detect the position of a motor rotor, a Hall sensor or a rotary encoder is used for detecting the position of the rotor in the prior art, advantages and disadvantages exist between the Hall sensor and the rotary encoder, and the specific device used for detecting the position of the rotor can be specifically determined according to the use requirement.
At present, incremental rotary encoders are used for detecting the positions of motor rotors, one of the problems is that pulse signals generated by one rotation circle of the incremental rotary encoders are many, and along with the increase of running time in the running process of the motors, the number of the pulse signals generated by the incremental rotary encoders is huge, so that the data processing number of control equipment (such as an MCU) is huge, the working efficiency of the control equipment is very low, the control equipment can not accurately control the motor phase change seriously, the normal running of the motor is influenced, and the user loss is caused.
Disclosure of Invention
In view of the above, the present invention provides a method and system for controlling a motor that greatly reduces the amount of data that needs to be processed by the control device.
The embodiment of the invention provides a method for controlling a motor, which is applied to a counter in an MCU (microprogrammed control Unit), wherein the counter is connected with a rotary encoder, and the method comprises the following steps:
acquiring a preset pulse value stored by the MCU, wherein the preset pulse value is a pulse value corresponding to a phase change point of the motor;
counting the pulse values generated by the rotary encoder, and comparing whether the currently counted pulse values are equal to the preset pulse values or not;
and sending an interrupt signal to the MCU under the condition that the currently counted pulse numerical value is equal to the preset pulse value, and simultaneously obtaining the next preset pulse value stored by the MCU, wherein the interrupt signal is used for enabling the MCU to carry out phase change operation on the motor.
Optionally, the counter comprises an input capture channel; before obtaining the preset pulse value stored by the MCU, the method further comprises the following steps:
capturing a first null pulse emitted by the rotary encoder through the input capture channel;
when the first zero pulse is captured through the input capture channel, clearing a count value of a pulse value generated by the rotary encoder, and setting the current position of the rotary encoder as the zero position of the rotary encoder;
and when the MCU is used for electrifying each phase of the motor through the driving circuit, counting pulse values generated in the process that the rotary encoder changes from a rotating state to a stopping state by taking the zero-degree position as an initial position to obtain the pulse values of the phase change points of the motor.
Optionally, the number of the preset pulse values is multiple; the counter further comprises: the pulse counting channel is used for counting pulse values generated by the rotary encoder, and the comparison register is used for storing preset pulse values stored by the obtained MCU; after sending an interrupt signal to the MCU, the method further comprises:
and triggering direct memory access through the pulse counting channel to obtain a next preset pulse value stored by the MCU, and storing the next preset pulse value in the comparison register.
Optionally, the rotary encoder corresponding to the preset pulse value takes the zero-degree position as a start position, and a pulse value generated in a process of changing from a rotating state to a stopping state is a phase change point of the motor.
The embodiment of the invention also provides a device for controlling the motor, which is applied to a counter in the MCU, wherein the counter is connected with the rotary encoder, and the device comprises:
the acquisition module is used for acquiring a preset pulse numerical value stored by the MCU, wherein the preset pulse numerical value is a pulse numerical value corresponding to the motor phase change point;
the counting comparison module is used for counting the pulse values generated by the rotary encoder and comparing whether the currently counted pulse values are equal to the preset pulse values or not;
and the sending interruption obtaining module is used for sending an interruption signal to the MCU and simultaneously obtaining the next preset pulse value stored by the MCU under the condition that the currently counted pulse value is equal to the preset pulse value, wherein the interruption signal is used for enabling the MCU to carry out phase change operation on the motor.
Optionally, the counter comprises an input capture channel; the device further comprises:
the capture module is used for capturing a first zero pulse emitted by the rotary encoder through the input capture channel;
the zero clearing module is used for clearing a count value of a pulse value generated by the rotary encoder when the first zero pulse is captured through the input capture channel and setting the current position of the rotary encoder as the zero position of the rotary encoder;
and the phase change point pulse value determining module is used for counting pulse values generated in the process that the rotary encoder changes from a rotating state to a stopping state by taking the zero-degree position as an initial position when the MCU energizes each phase of the motor through the driving circuit so as to obtain the pulse values of the phase change points of the motor.
Optionally, the number of the preset pulse values is multiple; the counter further comprises: the pulse counting channel is used for counting pulse values generated by the rotary encoder, and the comparison register is used for storing preset pulse values stored by the obtained MCU; the device further comprises:
and the trigger obtaining module is used for triggering the direct memory access through the pulse counting channel, obtaining the next preset pulse value stored by the MCU and storing the next preset pulse value in the comparison register.
An embodiment of the present invention further provides a system for controlling a motor, where the system includes: MCU, rotary encoder and motor, MCU includes: and the rotary encoder is respectively connected with the MCU and the motor, and the counter is used for executing any one of the methods.
Compared with the prior art, the method for controlling the motor, provided by the invention, comprises the steps of obtaining the preset pulse numerical value stored by the MCU, counting the pulse numerical value generated by the rotary encoder, comparing whether the currently counted pulse numerical value is equal to the preset pulse numerical value or not, sending an interrupt signal to the MCU under the condition that the currently counted pulse numerical value is equal to the preset pulse numerical value, so that the MCU carries out phase change operation on the motor, and obtaining the next preset pulse numerical value stored by the MCU while sending the interrupt signal to the MCU. The method does not need to change the existing circuit structure and the structure of each device, is simple and convenient, has high accuracy, can be adjusted adaptively according to the specific performance of the rotary encoder, and has clear and concise whole method, strong operability and wider application range.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart of a method of controlling a motor in accordance with an embodiment of the present invention;
FIG. 2 is a schematic view of a rotary encoder and counter according to an embodiment of the present invention;
fig. 3 is a block diagram of an apparatus for controlling a motor according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below. It should be understood that the specific embodiments described herein are merely illustrative of the invention, but do not limit the invention to only some, but not all embodiments.
The inventor finds that the incremental rotary encoder mainly has the following 3 technical problems when detecting the rotor position of the direct current brushless motor at present:
1. the signals generated by a typical incremental rotary encoder are only incremental in position, for example: after the motor is started, the motor rotates clockwise by 10 degrees to a position of 90 degrees, but the incremental rotary encoder can only detect that the motor rotor rotates by 10 degrees and does not know the current absolute position of the motor rotor, and the absolute position of the motor rotor must be known to determine the position of the motor rotor.
2. The general incremental rotary encoder is arranged outside the motor, the corresponding relation between the position of the rotor of the motor and the position of the phase change point of the motor obtained by the encoder is not clear, and the phase change of the motor is not known when the rotor rotates to some degrees.
3. The precision of the incremental rotary encoder is high, which divides 360 ° into thousands of parts, but this also results in thousands of pulse signals generated by the incremental rotary encoder per rotation of the motor, and the number of pulse signals is extremely huge after the motor is operated, which naturally causes great pressure to the operation of the control device.
Based on the above problems, the inventor of the present invention has made extensive research, combined with the characteristics of the MCU, and through a large number of field tests and simulation calculations, creatively proposed the method for controlling the motor of the present invention, in which the counter is used to complete the processing of the pulse signal, and the MCU only needs to execute the motor commutation, thereby solving the above problems. The solution proposed by the inventors is explained and illustrated in detail below.
Referring to fig. 1, a flowchart of a method of controlling a motor according to an embodiment of the present invention is shown, the method including:
step 101: and acquiring a preset pulse value stored by the MCU, wherein the preset pulse value is a pulse value corresponding to a motor phase change point.
In the embodiment of the present invention, referring to fig. 2, a schematic diagram of a rotary encoder and a counter according to the embodiment of the present invention is shown, where the counter is a module in an MCU, and is embedded in the MCU, and the counter has three channels, two of which are pulse counting channels, and are respectively connected to an output a phase and an output B phase of the rotary encoder, and the other is an input capture channel, and is connected to an output Z of the rotary encoder; the pulse counting channel is used for counting the pulse values of the A phase and the B phase output by the rotary encoder; the input capture channel is used for capturing zero pulses emitted by the output Z phase of the rotary encoder. The counter also has a compare register for holding a predetermined pulse value.
The MCU is stored with a preset pulse value, and the preset pulse value is a pulse value which is determined by the rotary encoder and corresponds to a motor phase change point. Before the motor is formally operated, the MCU writes a preset pulse value corresponding to the first commutation point into a comparison register of a counter according to the required steering of the motor, the counter has a channel comparison function, and the channel comparison function is as follows: and the function of comparing the value in the pulse counting channel in the counter with the value in the comparison register.
As an example: assume that the MCU chip used is: the GD32F303RCT6 comprises a counter, an incremental rotary encoder is rigidly connected with a motor rotor, 3600 pulse signals are generated by one rotation of the incremental rotary encoder, the corresponding motor rotor angle is 360 degrees, namely the rotating angle of the rotary encoder corresponding to each 10 pulse signals is 1 degree of the motor rotor angle, the preset pulse values are 300, 1500 and 2700, if the motor needs to rotate forwards, the MCU writes the first preset pulse value 300 into a comparison register of the counter before the motor is formally operated.
Optionally, before obtaining the preset pulse value stored by the MCU, it is first required to determine the preset pulse value, that is, it is required to determine how many degrees the rotary encoder rotates to reach the phase change point of the motor with the zero-degree position as the standard, that is, how many pulse values the rotary encoder generates with the zero-degree position as the standard reach the phase change point of the motor. The method for determining the zero-degree position and the preset pulse value comprises the following steps:
step S1: capturing a first zero pulse emitted by a rotary encoder through an input capturing channel;
in the embodiment of the invention, the zero position of the rotary encoder needs to be determined firstly, and the driving motor is rotated in a time-delay reversing mode until the first zero pulse signal on the Z phase of the rotary encoder is captured through the input capturing channel.
Step S2: when capturing a first zero pulse through an input capturing channel, clearing a count value of a pulse value generated by a rotary encoder, and setting the current position of the rotary encoder as a zero position of the rotary encoder;
in the embodiment of the invention, when the first zero pulse signal on the Z phase of the rotary encoder is captured through the input capture channel, the counter clears the count value of the pulse counting channel at the moment, and sets the current position as the zero position of the rotary encoder: 0 degrees, so that 0 degrees of the rotary encoder corresponds to 0 degrees of the counting value of the pulse counting channel, each pulse signal of the rotary encoder counts once, 3600 pulses can be generated by the rotary encoder per 360 degrees of rotation, namely, the counting value 10 corresponds to 1 degree of the rotary encoder. The zero-degree position of the rotary encoder is accurately positioned by adopting the method.
Step S3: when the MCU energizes each phase of the motor through the driving circuit, the rotary encoder counts pulse values generated in the process of changing from a rotating state to a stopping state by taking a zero-degree position as an initial position, and pulse values of phase change points of the motor are obtained.
In the embodiment of the invention, after the zero-degree position is determined, a pulse numerical value corresponding to a motor commutation point needs to be determined, namely a preset pulse numerical value, firstly, the MCU conducts long-time electrification on the AB phase of the motor through the driving circuit, a rotor of the motor is forced to stop at the position of the commutation point, then the MCU reads the pulse numerical value generated by the rotary encoder corresponding to the rotated angle when the rotary encoder rotates to the stop position by taking the zero-degree position as the initial position, the absolute position of the motor commutation point can be obtained, if the rotated angle of the rotary encoder relative to the zero-degree position is 10 degrees, the correspondingly generated pulse numerical value is 100, the first preset pulse numerical value is obtained, then, the BC phase is obtained in the same mode, and the CA phase is obtained in the same mode, and the third preset pulse numerical value is 2500. After all the preset pulse values are obtained, the preset pulse values are stored in the MCU. The method is adopted to accurately position the pulse numerical value of the rotary encoder corresponding to the phase change point of the motor.
Step 102: and counting the pulse values generated by the rotary encoder, and comparing whether the currently counted pulse values are equal to the preset pulse values.
In the embodiment of the invention, after the motor is started to operate formally, the counter counts the pulse value generated by the rotary encoder through the pulse counting channel. When the motor runs, each phase of the motor is sequentially electrified, the rotary encoder is driven to rotate through the motor rotor, the motor rotor is in rigid connection, the rotating angle of the motor rotor is the same as the rotating angle of the rotary encoder, in the rotating process of the rotary encoder, when the output phase A is the same as the output phase B, a pulse signal is generated, the phase difference between the output phase A and the output phase B is 90 degrees, and the pulse counting channel counts the pulse signals generated when the phase A is the same as the output phase B to obtain a pulse value. When the pulse counting channel of the counter counts, the current pulse value in the pulse counting channel is compared with the preset pulse value in the comparison register through a channel comparison function, and whether the current pulse value and the preset pulse value are equal is compared.
Following the above example: the output A phase and B phase of the incremental rotary encoder are respectively connected with a pulse counting channel, and if the incremental rotary encoder rotates by 1 degree, the output A phase and B phase of the incremental rotary encoder generate 10 pulse signals, and the pulse counting channel counts the 10 pulse signals to obtain a pulse value: 10. along with the motor rotation, the pulse counting channel can carry out real-time counting on the pulse signals generated by the rotary encoder to obtain a pulse value, if the pulse value is 100, the preset pulse value in the comparison register is 300, the channel comparison function of the counter compares the two values in real time, and along with the rotation of the rotary encoder, the pulse value of the pulse signals is increased until the currently counted pulse value is equal to the preset pulse value 300.
Step 103: and under the condition that the currently counted pulse value is equal to the preset pulse value, sending an interrupt signal to the MCU, and simultaneously obtaining the next preset pulse value stored by the MCU, wherein the interrupt signal is used for enabling the MCU to carry out phase change operation on the motor.
In the embodiment of the invention, under the condition that the currently counted pulse value of the pulse counting channel is equal to the preset pulse value, the counter sends an interrupt signal to the MCU, the MCU receives the interrupt signal and interrupts all operations, and the MCU controls the driving circuit to electrify the next phase of the motor according to the phase sequence required by the rotation direction of the motor, so that the motor is phase-changed and the motor continues to run. And when the counter sends an interrupt signal to the MCU, the counter triggers a Direct Memory Access (DMA) technology to obtain the next preset pulse value from the MCU by the DMA, and the next preset pulse value is stored in a comparison register.
Following the above example: assuming that the motor is a single-stage motor and rotates forwards, when the motor operates, the AB phase of the motor is firstly electrified, when the real-time counting value of a pulse signal generated by a pulse counting channel to a rotary encoder reaches 300, the counting channel is equal to the preset pulse value of 300, a counter sends an interrupt signal to an MCU (microprogrammed control unit), the MCU controls a driving circuit to electrify a motor BC according to the forward rotation electrifying phase sequence of the motor, and then the motor continues to rotate and operate. When the counter sends an interrupt signal to the MCU, the counter triggers the DMA to obtain the next preset pulse value from the MCU: 1500 and save 1500 in the compare register.
In summary, assuming that the motor is a single-stage motor and needs to be rotated reversely, 1800 pulse signals are generated by the rotary encoder during one rotation, the zero position of the rotary encoder needs to be determined first, the driving motor is rotated in a "delayed commutation" manner until a zero pulse signal is detected to be generated on the Z phase of the rotary encoder, at this time, the count value of the pulse counting channel in the counter is cleared, and the current position is set as the zero position of the rotary encoder: 0 ° so that 0 ° of the rotary encoder corresponds to 0 ° of the count value of the pulse count channel, each pulse signal of the rotary encoder counts once, 1800 pulses are generated per 360 ° revolution of the rotary encoder, i.e., the count value 50 corresponds to 1 ° of the rotary encoder.
After the zero-degree position of the rotary encoder is determined, a pulse numerical value corresponding to a motor commutation point is determined, namely a preset pulse numerical value, firstly, the MCU conducts long-time electrification on the AB phase of the motor through the driving circuit, the rotor of the motor is forced to stop at the position of the commutation point, then, the pulse numerical value correspondingly generated by the current rotary encoder relative to the angle rotated by the zero-degree position is read, the absolute position of the motor commutation point can be obtained, if the angle rotated by the rotary encoder relative to the zero-degree position is 6 degrees, the pulse numerical value correspondingly generated is 300, namely the first preset pulse numerical value, then, the BC phase is subjected to the same mode to obtain a second preset pulse numerical value 1500, and the CA phase is subjected to the same mode to obtain a third preset pulse numerical value 2700. These three preset pulse values are stored in the MCU.
Assuming that the value of the real-time counting of the pulse signal generated by the rotary encoder by the pulse counting channel reaches 1000 when the motor stops last time, when the motor normally starts to normally operate this time, first a first preset pulse value 1500 is written into a comparison register in the counter, then the BC is electrified, the rotary encoder continuously generates the pulse signal along with the operation of the motor, the pulse counting channel starts to count the pulse signal in real time by 1000, and the counter compares the count value in the pulse counting channel with the preset pulse value in the comparison register in real time.
When the real-time counting value of the pulse signal generated by the rotary encoder through the pulse counting channel reaches 1500, the real-time counting value is equal to the preset pulse value 1500, the counter sends an interrupt signal to the MCU, the MCU controls the driving circuit to conduct electricity for the motor CA according to the forward rotation electrifying phase sequence of the motor, and then the motor continues to rotate and run. When the counter sends an interrupt signal to the MCU, the counter triggers the DMA to obtain the next preset pulse value from the MCU: 2700 and saves 2700 in the compare register. When the value of the pulse signal real-time count generated by the pulse counting channel to the rotary encoder reaches 2700, the pulse counting channel is equal to the preset pulse value 2700, the counter sends an interrupt signal to the MCU, the MCU controls the driving circuit to be electrified for the motor AB according to the motor reversal electrifying phase sequence, and then the motor continues to rotate and run. When the counter sends an interrupt signal to the MCU, the counter triggers the DMA to obtain the next preset pulse value from the MCU: 300 and stores 300 in the compare register.
The rotary encoder continuously generates pulse signals along with the continuous operation of the motor, when the real-time counting value of the pulse signals generated by the rotary encoder reaches 3600 through the pulse counting channel, the rotary encoder rotates for 360 degrees for one circle, so that zero-position pulses are emitted by the output Z phase of the rotary encoder, when the zero-position pulses are captured by the counter through the input capturing channel, the counting value of the pulse counting channel is cleared, and the pulse values generated by the pulse counting channel to the rotary encoder start to be counted again from 0.
When the real-time counting value of the pulse signal generated by the rotary encoder through the pulse counting channel reaches 300, the pulse counting channel is equal to the preset pulse value 300, the counter sends an interrupt signal to the MCU, the MCU controls the driving circuit to conduct electricity for the motor BC according to the reverse power-on phase sequence of the motor, and then the motor continues to rotate and run. When the counter sends an interrupt signal to the MCU, the counter triggers the DMA to obtain the next preset pulse value from the MCU: 1500 and save 1500 in the compare register.
And repeating the steps, so as to ensure the normal reverse rotation operation of the motor until the motor stops operating.
It should be noted that, if the rotary encoder is loose for various reasons and cannot ensure that the rotation of the rotary encoder is synchronous with the rotation of the motor rotor, or the MCU loses power, the rotary encoder is fixed again to achieve the rotation synchronization with the motor rotor, or after the MCU is powered again, the rotary encoder needs to determine the zero position and determine the commutation point again, which is to ensure that the rotary encoder can accurately detect the absolute position of the motor rotor, so as to achieve the purpose of the MCU accurately controlling the commutation of the motor.
Fig. 3 is a block diagram showing an apparatus for controlling a motor according to an embodiment of the present invention, the apparatus being applied to a counter in an MCU, the counter being connected to a rotary encoder, the apparatus for controlling a motor including:
an obtaining module 310, configured to obtain a preset pulse value stored by the MCU, where the preset pulse value is a pulse value corresponding to a phase change point of the motor;
a counting and comparing module 320, configured to count a pulse value generated by the rotary encoder, and compare whether the currently counted pulse value is equal to a preset pulse value;
and a sending interruption obtaining module 330, configured to send an interruption signal to the MCU when the currently counted pulse value is equal to the preset pulse value, and obtain a next preset pulse value stored by the MCU at the same time, where the interruption signal is used to enable the MCU to perform a phase change operation on the motor.
Optionally, the counter comprises an input capture channel; the apparatus for controlling a motor further includes:
the capture module is used for capturing a first zero pulse emitted by the rotary encoder through an input capture channel;
the zero clearing module is used for clearing a count value of a pulse value generated by the rotary encoder when capturing a first zero pulse through the input capturing channel and setting the current position of the rotary encoder as the zero position of the rotary encoder;
and the phase change point pulse value determining module is used for counting pulse values generated in the process that the rotary encoder changes from a rotating state to a stopping state by taking a zero-degree position as an initial position when the MCU energizes each phase of the motor through the driving circuit to obtain the pulse values of the phase change points of the motor.
Optionally, the number of the preset pulse values is multiple; the counter further comprises: the pulse counting channel is used for counting pulse values generated by the rotary encoder, and the comparison register is used for storing and obtaining preset pulse values stored by the MCU; the apparatus for controlling a motor further includes:
and the trigger acquisition module is used for triggering the direct memory access through the pulse counting channel, acquiring the next preset pulse value stored by the MCU and storing the next preset pulse value in the comparison register.
An embodiment of the present invention further provides a system for controlling a motor, where the system includes: MCU, rotary encoder and motor, MCU includes: and the counter is connected with the MCU and the motor respectively and used for executing any one of the methods.
In conclusion, the method, the device and the system for controlling the motor do not need to change the existing circuit structure and the structure of each device in the using process, are simple, convenient and high in accuracy, can be adjusted adaptively according to the specific performance of the rotary encoder, and have the advantages of clear and concise whole method, strong operability and wider application range.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Claims (8)

1. A method of controlling an electric motor, the method being applied to a counter in an MCU, the counter being connected to a rotary encoder, the method comprising:
acquiring a preset pulse value stored by the MCU, wherein the preset pulse value is a pulse value corresponding to a phase change point of the motor;
counting the pulse values generated by the rotary encoder, and comparing whether the currently counted pulse values are equal to the preset pulse values or not;
and sending an interrupt signal to the MCU under the condition that the currently counted pulse numerical value is equal to the preset pulse value, and simultaneously obtaining the next preset pulse value stored by the MCU, wherein the interrupt signal is used for enabling the MCU to carry out phase change operation on the motor.
2. The method of claim 1, wherein the counter comprises an input capture channel; before obtaining the preset pulse value stored by the MCU, the method further comprises the following steps:
capturing a first null pulse emitted by the rotary encoder through the input capture channel;
when the first zero pulse is captured through the input capture channel, clearing a count value of a pulse value generated by the rotary encoder, and setting the current position of the rotary encoder as the zero position of the rotary encoder;
and when the MCU is used for electrifying each phase of the motor through the driving circuit, counting pulse values generated in the process that the rotary encoder changes from a rotating state to a stopping state by taking the zero-degree position as an initial position to obtain the pulse values of the phase change points of the motor.
3. The method of claim 1, wherein the number of the preset pulse number values is plural; the counter further comprises: the pulse counting channel is used for counting pulse values generated by the rotary encoder, and the comparison register is used for storing preset pulse values stored by the obtained MCU; after sending an interrupt signal to the MCU, the method further comprises:
and triggering direct memory access through the pulse counting channel to obtain a next preset pulse value stored by the MCU, and storing the next preset pulse value in the comparison register.
4. The method according to claim 1, wherein the rotary encoder corresponding to the preset pulse value takes the zero degree position as a starting position, and a pulse value generated in a process of changing from a rotating state to a stopping state is a phase change point of the motor.
5. A device for controlling an electric motor, said device being applied to a counter in an MCU, said counter being connected to a rotary encoder, said device comprising:
the acquisition module is used for acquiring a preset pulse numerical value stored by the MCU, wherein the preset pulse numerical value is a pulse numerical value corresponding to the motor phase change point;
the counting comparison module is used for counting the pulse values generated by the rotary encoder and comparing whether the currently counted pulse values are equal to the preset pulse values or not;
and the sending interruption obtaining module is used for sending an interruption signal to the MCU and simultaneously obtaining the next preset pulse value stored by the MCU under the condition that the currently counted pulse value is equal to the preset pulse value, wherein the interruption signal is used for enabling the MCU to carry out phase change operation on the motor.
6. The apparatus of claim 5, wherein the counter comprises an input capture channel; the device further comprises:
the capture module is used for capturing a first zero pulse emitted by the rotary encoder through the input capture channel;
the zero clearing module is used for clearing a count value of a pulse value generated by the rotary encoder when the first zero pulse is captured through the input capture channel and setting the current position of the rotary encoder as the zero position of the rotary encoder;
and the phase change point pulse value determining module is used for counting pulse values generated in the process that the rotary encoder changes from a rotating state to a stopping state by taking the zero-degree position as an initial position when the MCU energizes each phase of the motor through the driving circuit so as to obtain the pulse values of the phase change points of the motor.
7. The apparatus of claim 5, wherein the number of the preset pulse number values is plural; the counter further comprises: the pulse counting channel is used for counting pulse values generated by the rotary encoder, and the comparison register is used for storing preset pulse values stored by the obtained MCU; the device further comprises:
and the trigger obtaining module is used for triggering the direct memory access through the pulse counting channel, obtaining the next preset pulse value stored by the MCU and storing the next preset pulse value in the comparison register.
8. A system for controlling an electric machine, the system comprising: MCU, rotary encoder and motor, MCU includes: a counter, said rotary encoder being connected to said MCU and said motor respectively, said counter being adapted to perform the method of any of claims 1-4.
CN201910746130.2A 2019-08-13 2019-08-13 Method, device and system for controlling motor Pending CN110601605A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910746130.2A CN110601605A (en) 2019-08-13 2019-08-13 Method, device and system for controlling motor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910746130.2A CN110601605A (en) 2019-08-13 2019-08-13 Method, device and system for controlling motor

Publications (1)

Publication Number Publication Date
CN110601605A true CN110601605A (en) 2019-12-20

Family

ID=68854071

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910746130.2A Pending CN110601605A (en) 2019-08-13 2019-08-13 Method, device and system for controlling motor

Country Status (1)

Country Link
CN (1) CN110601605A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114527832A (en) * 2022-01-02 2022-05-24 深圳市禾望电气股份有限公司 Pulse signal edge measuring method and device, storage medium and micro control unit

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101409523A (en) * 2008-12-01 2009-04-15 哈尔滨理工大学 Method for determining initial position of permanent magnet motor magnetic pole through incremental encoder
CN101594114A (en) * 2009-07-02 2009-12-02 哈尔滨工业大学 Method for determining initial position angle of rotor of permanent magnet synchronous motor
CN102820840A (en) * 2011-06-10 2012-12-12 北京理工大学 Method for sampling current of brushless direct current motor
CN103322896A (en) * 2013-07-10 2013-09-25 江苏浩峰汽车附件有限公司 Detection method and system for mounting position of Hall sensor of brushless direct current motor
CN106253764A (en) * 2015-08-28 2016-12-21 沈阳工业大学 The novel sensor signal processing method of polyphase machine rotor magnetic pole position detection
CN109327167A (en) * 2017-07-31 2019-02-12 杭州海康威视数字技术股份有限公司 A kind of motor apparatus and method of motor control, controller

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101409523A (en) * 2008-12-01 2009-04-15 哈尔滨理工大学 Method for determining initial position of permanent magnet motor magnetic pole through incremental encoder
CN101594114A (en) * 2009-07-02 2009-12-02 哈尔滨工业大学 Method for determining initial position angle of rotor of permanent magnet synchronous motor
CN102820840A (en) * 2011-06-10 2012-12-12 北京理工大学 Method for sampling current of brushless direct current motor
CN103322896A (en) * 2013-07-10 2013-09-25 江苏浩峰汽车附件有限公司 Detection method and system for mounting position of Hall sensor of brushless direct current motor
CN106253764A (en) * 2015-08-28 2016-12-21 沈阳工业大学 The novel sensor signal processing method of polyphase machine rotor magnetic pole position detection
CN109327167A (en) * 2017-07-31 2019-02-12 杭州海康威视数字技术股份有限公司 A kind of motor apparatus and method of motor control, controller

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114527832A (en) * 2022-01-02 2022-05-24 深圳市禾望电气股份有限公司 Pulse signal edge measuring method and device, storage medium and micro control unit
CN114527832B (en) * 2022-01-02 2024-04-02 深圳市禾望电气股份有限公司 Pulse signal edge measuring method and device, storage medium and micro-control unit

Similar Documents

Publication Publication Date Title
US5652494A (en) Angle controller for a switched reluctance drive utilizing a high frequency clock
US5650779A (en) Position encoder
CN101834555A (en) Speed detect circuit and motor driver apparatus with this speed detect circuit
WO2009065038A1 (en) Extrapolation of back emf signals in brushless dc motors
WO2018076937A1 (en) Voice coil electric motor control method and system, and controller
CN105305755A (en) Detection method for rotor position of permanent-magnet synchronous motor
CN103322896A (en) Detection method and system for mounting position of Hall sensor of brushless direct current motor
CN110601605A (en) Method, device and system for controlling motor
CN115021632A (en) Motor operation detection method and device, computer equipment and motor control device
CN107482968B (en) control method for improving motion precision of direct current motor
CN113060149B (en) Method, device and system for detecting crankshaft position of hybrid electric vehicle and electronic equipment
CN109172935B (en) Device and method for detecting driving direction and accuracy of infusion pump
CN107340472B (en) A kind of detection device and method of stepper motor motion state
CN102608438B (en) Method for determining corresponding relation of phase sequence of stator winding and encoder
CN103580578A (en) Method for acquiring angle increment when brushless direct-current motor is started in sine-wave mode
US9748879B2 (en) Motor drive controller and control method of motor drive controller
CN101719755B (en) Method and device for checking lost steps of stepping motor and impedance matching device
CN107659225B (en) Position detection device of permanent magnet synchronous motor with low cost and high reliability
CN104767467A (en) Method for calibrating mechanical zero of motor
CN102621405B (en) Device for detecting stator winding phase sequence and encoder output level
CN114070161A (en) Control method of multi-zero signal orthogonal encoder
CN109905059B (en) Sensorless direct current brushless motor control method and device
CN112751520A (en) Computer equipment, storage medium, and method, device and system for detecting state of servo motor
US6310458B1 (en) Blended velocity estimation
CN204128573U (en) Motor position on a kind of sewing machine detects sensing device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20201202

Address after: Room 703, 7 / F, building N1, No. 88, Dongchang Road, Suzhou Industrial Park, Suzhou, Jiangsu Province 215008

Applicant after: SUZHOU FURUISI INFORMATION TECHNOLOGY Co.,Ltd.

Applicant after: HEFEI GEYI INTEGRATED CIRCUIT Co.,Ltd.

Applicant after: Beijing Zhaoyi Innovation Technology Co.,Ltd.

Address before: 230601 No. 368 Tsinghua Road, Hefei Economic and Technological Development Zone, Anhui Province

Applicant before: HEFEI GEYI INTEGRATED CIRCUIT Co.,Ltd.

Applicant before: Beijing Zhaoyi Innovation Technology Co.,Ltd.

RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20191220