Position calculation method based on synchronous motor photoelectric encoder and storage medium

文档序号:1829244 发布日期:2021-11-12 浏览:24次 中文

阅读说明:本技术 基于同步电机光电编码器的位置计算方法及存储介质 (Position calculation method based on synchronous motor photoelectric encoder and storage medium ) 是由 曾小凡 文宇良 梅文庆 黄佳德 郑汉锋 张朝阳 连国一 杨帆 于 2020-05-11 设计创作,主要内容包括:本发明提供了一种同步电机光电编码器的位置计算方法,该方法包括:在电机转动时,实时获取光电编码器中光电检测装置输出的当前电平信息并记录当前电平信息的持续时间t,将实时获取的当前电平信息与前次获取的电平信息进行比较,根据比较结果确定光电编码器的当前齿数n;根据当前齿数n和当前电平信息的持续时间t计算光电编码器中光栅盘的当前位置角,本发明中的方案能够避免因使用旋转变压器成本高,解码复杂的问题,从而降低成本,提高效率。(The invention provides a position calculation method of a synchronous motor photoelectric encoder, which comprises the following steps: when the motor rotates, acquiring current level information output by a photoelectric detection device in the photoelectric encoder in real time, recording the duration time t of the current level information, comparing the current level information acquired in real time with the level information acquired last time, and determining the current tooth number n of the photoelectric encoder according to the comparison result; the current position angle of the grating disk in the photoelectric encoder is calculated according to the current tooth number n and the duration time t of the current level information.)

1. A position calculation method based on a synchronous motor photoelectric encoder is characterized by comprising the following steps:

when the motor rotates, acquiring current level information output by a photoelectric detection device in the photoelectric encoder in real time, recording the duration time t of the current level information, comparing the current level information acquired in real time with the level information acquired last time, and determining the current tooth number n of the photoelectric encoder according to the comparison result;

and determining the current position angle of the grating disk in the photoelectric encoder according to the current tooth number n and the duration time t of the current level information.

2. The method of claim 1, wherein the determining the current position angle of the grating disk in the photoelectric encoder according to the current tooth number n and the duration t of the current level information is calculated by:

wherein, ω iseThe number of the motor rotating speed is p, the number of the motor pole pairs is p, and the number of the grating grooves is N.

3. The method of claim 1, wherein determining the current number n of teeth of the optical-to-electrical encoder based on the comparison comprises:

if the current level information is consistent with the level information acquired last time, keeping the current tooth number n unchanged;

if the current level information is not consistent with the level information acquired last time, the number n of the current teeth is increased, the duration time of the level information acquired last time is recorded, and the duration time of the current level information is set to be 0.

4. The method according to claim 3, wherein if the current level information is not identical to the level information obtained last time, the current number of teeth n is increased, including:

and judging whether the pulse formed by the level information acquired last time is a missing tooth pulse, if so, adding 2 to the current tooth number n, and otherwise, adding 1 to the current tooth number n.

5. The method according to claim 4, wherein the determining whether the pulse formed by the level information acquired last time is a missing tooth pulse comprises: if the duration of the level information acquired last time exceeds 2 times of the duration of the level information acquired before the level information acquired last time, the pulse formed by the level information acquired last time is determined to be a missing tooth pulse.

6. The method according to claim 4, further comprising setting an out-of-teeth flag, wherein the initial out-of-teeth flag is set to 0, and wherein the out-of-teeth flag is set to 1 when the pulse formed by the level information obtained at the previous time is an out-of-teeth pulse.

7. The method of claim 6, further comprising:

and when the current tooth number is greater than N-2 and the gear missing mark is 0 or the current tooth number is greater than N and the gear missing mark is 1, setting the current tooth number to 0 and setting the gear missing mark to 0.

8. A storage medium having a computer program stored thereon, wherein the computer program is executable by one or more controllers to implement the synchronous motor photoelectric encoder based position calculation method of any one of claims 1 to 7.

9. An electronic device, characterized in that the electronic device comprises a memory and a controller, the memory stores program codes which can be executed by the controller, and when the program codes are executed by the controller, the method for calculating the position based on the synchronous motor photoelectric encoder is realized according to any one of claims 1 to 7.

10. A closed-loop control system based on a synchronous motor is characterized by comprising a photoelectric encoder, a memory and a controller;

the photoelectric encoder comprises a grating disc and a photoelectric detection device, wherein the grating disc is driven by an output shaft of the synchronous motor to rotate; the photoelectric detection device is arranged to output corresponding level information according to the rotation of the grating disk;

the memory stores program code executable by the controller, and when the program code is executed by the controller, the program code determines the current position angle of the grating disk in the photoelectric encoder based on the position calculation method based on the synchronous motor photoelectric encoder according to any one of claims 1 to 7, based on the level information output by the photoelectric detection device in the photoelectric encoder;

the controller is further configured to perform closed-loop control of the synchronous motor based on a current position angle of a grating disk in the photoelectric encoder.

Technical Field

The invention relates to the field of synchronous motor real-time position calculation, in particular to a position calculation method based on a synchronous motor photoelectric encoder and a storage medium.

Background

Real-time position and speed signals need to be known in the closed-loop control of the synchronous motor, a physical position sensor is generally adopted for detection, the position sensor generally adopts a rotary transformer, the precision of the rotary transformer is high, but the rotary transformer is expensive, the decoding of analog signals is complex, a photoelectric encoder directly outputs digital signals, the price is low, the output digital signals can be converted into position signals after being processed, and the synchronous motor is suitable for a certain application field.

The photoelectric encoder has the main working principle of photoelectric conversion, and is a sensor for converting mechanical geometric displacement of an output shaft into pulse or digital quantity through the photoelectric conversion. The grating disk and the motor are coaxial, so that the motor rotates to drive the grating disk to rotate, the photoelectric detection device outputs pulse signals, and position and rotating speed information is calculated according to the output pulse signals.

In some occasions, limited by installation and other reasons, one tooth of the photoelectric encoder is removed, and for a multi-pole synchronous motor, because the number of the gratings is limited, each tooth corresponds to a larger electrical angle, if the problem of missing teeth is not processed, a large position angle deviation is caused, the control performance is further deteriorated, and even the risk of overcurrent exists, so that the processing is required.

Disclosure of Invention

In order to solve the problems, the application provides a position calculation method and a storage medium based on a synchronous motor photoelectric encoder, so as to solve the problems that the real-time position feedback of a synchronous motor adopts a position sensor to obtain high cost and complex decoding.

In order to achieve the above object, in a first aspect of embodiments of the present invention, there is provided a position calculation method based on a synchronous motor photoelectric encoder, including: when the motor rotates, acquiring current level information output by a photoelectric detection device in the photoelectric encoder in real time, recording the duration time t of the current level information, comparing the current level information acquired in real time with the level information acquired last time, and determining the current tooth number n of the photoelectric encoder according to the comparison result; and calculating the current position angle of the grating disk in the photoelectric encoder according to the current tooth number n and the duration time t of the current level information.

Optionally, the calculation formula for determining the current position angle of the grating disk in the photoelectric encoder according to the current tooth number n and the duration t of the current level information is as follows:

wherein ω iseThe number of the motor rotating speed is p, the number of the motor pole pairs is p, and the number of the grating grooves is N.

Optionally, the determining the current tooth number n of the photoelectric encoder according to the comparison result includes:

if the current level information is consistent with the level information at the previous moment, keeping the current tooth number n unchanged;

if the current level information is not consistent with the level information at the previous moment, the number n of the current teeth is increased, the duration of the level information acquired last time is recorded, and the duration of the current level information is set to be 0.

Optionally, if the current level information is not consistent with the level information obtained last time, the current tooth number n is increased, including: and judging whether the pulse formed by the level information acquired last time is a missing tooth pulse, if so, adding 2 to the current tooth number n, and otherwise, adding 1 to the current tooth number n.

Optionally, the determining whether a pulse formed by the level information acquired last time is a missing tooth pulse includes: if the duration of the level information acquired last time exceeds 2 times of the duration of the level information acquired before the level information acquired last time, the pulse formed by the level information acquired last time is determined to be a missing tooth pulse.

Optionally, the method further includes setting a missing tooth flag, setting the initial missing tooth flag to 0, and setting the missing tooth flag to 1 when the pulse formed by the level information obtained at the current time is the missing tooth pulse.

Optionally, the method further comprises setting the current tooth number to 0 and the tooth missing flag to 0 when the current tooth number is greater than N-2 and the tooth missing is 0 or the current tooth number is greater than N and the tooth missing flag is 1.

In a second aspect of the embodiments of the present invention, there is provided a storage medium having a computer program stored thereon, where the computer program can be executed by one or more controllers to implement the position calculating method based on the synchronous motor photoelectric encoder according to any one of the first aspect.

In a third aspect of the embodiments of the present invention, there is provided an electronic device, which includes a memory and a controller, where the memory stores program codes executable by the controller, and when the program codes are executed by the controller, the method for calculating a position based on a synchronous motor photoelectric encoder according to any one of the first aspect is implemented.

In a fourth aspect of the embodiments of the present invention, a closed-loop control system based on a synchronous motor is provided, where the closed-loop control system includes a photoelectric encoder, a memory, and a controller; the photoelectric encoder comprises a grating disc and a photoelectric detection device, wherein the grating disc is driven by an output shaft of the synchronous motor to rotate; the photoelectric detection device is arranged to output corresponding level information according to the rotation of the grating disk; the memory stores program code executable by the controller, and when the program code is executed by the controller, the program code determines the current position angle of the grating disk in the photoelectric encoder based on the position calculation method based on the synchronous motor photoelectric encoder according to any one of the first aspect; the controller is further configured to perform closed-loop control of the synchronous motor based on a current position angle of a grating disk in the photoelectric encoder.

By adopting the technical scheme, the following technical effects can be at least achieved:

the invention realizes the position feedback of the synchronous motor by a software method and based on the photoelectric encoder, and can avoid the problems of high cost and complex decoding caused by using a rotary transformer, thereby reducing the cost and improving the efficiency.

The invention also solves the problem of position angle deviation of the synchronous motor during real-time position feedback easily under the condition that the photoelectric encoder lacks teeth through a software method, thereby improving the position precision of real-time feedback and the control performance of the synchronous motor.

Drawings

The scope of the invention will be better understood from the following detailed description of exemplary embodiments, read in conjunction with the accompanying drawings. Wherein the included drawings are:

fig. 1 is a schematic diagram of an optical encoder in a normal state according to an embodiment of the present invention.

Fig. 2 is a schematic diagram of an operation of an optical encoder under a tooth missing condition according to an embodiment of the present invention.

Fig. 3 is a flowchart of a position calculation method based on a synchronous motor photoelectric encoder according to an embodiment of the present invention.

In the drawings, like parts are designated with like reference numerals, and the drawings are not drawn to scale.

Detailed Description

The following detailed description of the embodiments of the present invention will be provided with reference to the accompanying drawings and examples, so that how to apply the technical means to solve the technical problems and achieve the corresponding technical effects can be fully understood and implemented. Various modifications may be made and equivalents may be substituted for elements thereof without departing from the scope of the invention. The embodiments and the features of the embodiments can be combined without conflict, and the technical solutions formed are all within the scope of the present invention.

The inventor of the invention researches and discovers that real-time position and speed signals need to be known in the closed-loop control of the synchronous motor, and a physical position sensor is generally adopted for detection, but the position sensor is expensive and the analog signal decoding is complex; the photoelectric encoder can directly output digital signals, the output digital signals can be converted into position signals through processing, and the position signals can be used for real-time position feedback of the synchronous motor, so that the problems that a rotary transformer is high in cost and complex in decoding due to the use of a position sensor are solved, the cost is reduced, and the efficiency is improved.

Fig. 1 shows a schematic diagram of the operation of a photoelectric encoder under normal conditions, that is, fig. 1 shows a grating disk of the photoelectric encoder, wherein 1 represents that when a light-emitting element irradiates a position, an output pulse is at a high level, 0 represents that when the light-emitting element irradiates the position, the output pulse is at a low level, when a motor does not rotate, a fixed high level signal or a fixed low level signal is output, and when the motor rotates at a certain speed, alternating high and low level signals with equal duration are output.

One circle of grating disk of photoelectric encoder is 2 pi radian, under the condition of no missing tooth, the number of pole pairs of motor is P, the number of grating grooves is N, and the electric angle is P times of mechanical angle, so that the electric angle corresponding to each groove is

FIG. 2 shows the working principle diagram of the photoelectric encoder in the case of missing teeth, i.e. FIG. 2 shows the output pulses of the grating disk in the case of missing teeth, according to the display of FIG. 2, because of the missing teeth, the output time of the missing tooth slot for a low level is the time of three normal slots, and the corresponding electrical angle isIf the missing teeth are not considered, a large error occurs in the calculation of the position angle.

Example one

Referring to fig. 3, an embodiment of the present invention provides a position calculating method based on a synchronous motor photoelectric encoder, including:

when the motor rotates, acquiring current level information output by a photoelectric detection device in the photoelectric encoder in real time, recording the duration time t of the current level information, comparing the current level information acquired in real time with the level information acquired last time, and determining the current tooth number n of the photoelectric encoder according to the comparison result;

according to the formulaDetermining a current position angle of a grating disk in a photoelectric encoder, where ωeThe motor rotating speed can be obtained through the level change rate, p is the number of pole pairs of the motor, and N is the number of grating grooves.

Because the change of the level information can affect the change of the number of teeth of the photoelectric encoder, the current level information acquired in real time is compared with the level information acquired last time, and the current number of teeth n of the photoelectric encoder is determined according to the comparison result to be divided into the following two conditions:

if the current level information is consistent with the level information acquired last time, the current tooth number n is kept unchanged;

if the current level information is not consistent with the level information acquired last time, the number n of the current teeth is increased, the duration time of the level information acquired last time is recorded, and the duration time of the current level information is set to be 0.

For the situation that the current level information acquired in real time is inconsistent with the level information acquired last time, if the tooth space of the photoelectric encoder is complete, the current tooth number n is only required to be added by 1 when the level information changes, and the duration time of the current level information is set to be 0 because the current level information just changes.

Because the photoelectric encoder is limited in installation, there may be a case where one tooth is removed from the photoelectric encoder, and therefore, when the level information changes, in the case of tooth missing, the grating disk may have already operated by an angle of one more tooth, and therefore, the current tooth number is not only 1 added on the basis of the tooth number obtained last time, but 2 added on the basis of the tooth number obtained last time.

In addition, because the number of grating grooves of the photoelectric encoder is N, when the motor rotates for one circle and the number of teeth of the photoelectric encoder reaches N, zero clearing is needed, and then the circular calculation is continued. However, due to the fact that the missing tooth condition exists, if the missing tooth condition occurs in the zero position, the current tooth number of the motor cannot reach N when the motor rotates for one circle, therefore, the tooth number is unreasonable to be cleared when the current tooth number is N, in order to prevent zero-degree positioning, the position of the missing tooth pulse is determined, a missing tooth mark is added, and when the missing tooth pulse is determined, the missing tooth mark is set to be 1. If the gear missing flag is 1, resetting the current gear number N when the current gear number N is greater than N, namely, no gear missing occurs at the zero position; and if the gear missing flag is always 0, clearing the current gear number N when the current gear number N is greater than N-2.

Because the photoelectric encoder has no absolute zero position, in order to determine the absolute zero position, a motor direct current positioning method is adopted at first, and a rotor shaft of the motor is pulled to the position of the phase axis of the motor A. The position angle at this time is set to zero.

Example two

The present embodiments provide a storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, etc., having stored thereon a computer program that is executable by one or more controllers, the computer program when executed by the controllers implementing the method steps of:

when the motor rotates, acquiring current level information output by the photoelectric encoder in real time, recording the duration time t of the current level information, comparing the current level information acquired in real time with the level information acquired last time, and determining the current tooth number n of the photoelectric encoder according to the comparison result;

according to a formulaDetermining a current position angle of the photoelectric encoder, wherein ωeThe number of the motor rotating speed is p, the number of the motor pole pairs is p, and the number of the grating grooves is N.

The specific embodiment of the above method steps can refer to the specific embodiment of the position calculation method based on the synchronous motor photoelectric encoder in the present invention, and details are not repeated here.

EXAMPLE III

The present embodiment provides an electronic device including a memory and a controller; the memory stores program code executable by the controller, and the program code is executed by the controller to implement the steps of the first embodiment.

The controller has the capability of processing and executing a program, both a general controller and a microcontroller are adopted, and a program code of the position calculation method based on the synchronous motor photoelectric encoder refers to a first specific embodiment of the position calculation method based on the synchronous motor photoelectric encoder in the invention at the execution time of the controller, and is not described again here.

Example four in real time

The embodiment provides a closed-loop control system based on a synchronous motor, which comprises a photoelectric encoder, a memory and a controller;

the photoelectric encoder comprises a grating disc and a photoelectric detection device, wherein the grating disc is driven by an output shaft of the synchronous motor to rotate; the photoelectric detection device is arranged to output corresponding level information according to the rotation of the grating disk;

the memory stores program codes which can be executed by the controller, and when the program codes are executed by the controller, the current position angle of the grating disk in the photoelectric encoder is determined according to the level information output by the photoelectric detection device in the grating encoder based on the position calculation method based on the synchronous motor photoelectric encoder in the first embodiment;

the controller is further configured to perform closed-loop control of the synchronous motor based on a current position angle of a grating disk in the photoelectric encoder.

The controller has both control and execution functions, and the method implemented when the program code of the position calculation method based on the synchronous motor photoelectric encoder running on the controller is executed can refer to the first specific embodiment of the position calculation method based on the synchronous motor photoelectric encoder of the present invention, and is not described herein again.

It should be understood that the disclosed methods and apparatus may be implemented in other ways. The apparatus embodiments described above are merely illustrative and, for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.

Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.

10页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于透射与反射式方案的编码器

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类