Interpolation method of encoder pulses, lidar and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-29
- Publication Date
- 2026-08-11
AI Technical Summary
[0002]相关技术中,编码器的码盘包括光栅式码盘和机械码盘,比较而言,光栅式码盘需要对光源发出的光进行反射,反光区域一旦沾上粉尘或者油污,反光性能将下降,因此,光栅式码盘对材质的要求较高,且由于光栅式码盘的分辨率较高,因此光栅式码盘的材料成本以及加工成本均较高;而机械码盘对材质以及抗尘、抗油污性能的要求不高,但是分辨率较低
[0032]基于本申请提供的编码器脉冲的插值方法、激光雷达以及存储介质, 通过获取所述机械码盘在待插值的脉冲周期内的平均转速,以及获取所述机械码盘在参考时长内的参考平均转速;然后根据所述平均转速、所述参考平均转速以及目标角度分辨率确定用于插入上升沿脉冲的插入时间间隔;最后在所述待插值的脉冲周期内,自所述待插值的脉冲周期的起始时间点每间隔一所述插入时间间隔向所述待插值的脉冲周期插入所述上升沿脉冲,因此,能够在无需改变机械式编码器的现有结构,也即不增加透光区数量的基础上,能够提高机械式编码器的分辨率,且相比于光栅式编码器能够降低成本。
Smart Images

Figure CN117516601B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of encoder technology, and in particular to an encoder pulse interpolation method, a lidar, and a storage medium. Background Technology
[0002] In related technologies, encoder code disks include grating code disks and mechanical code disks. In comparison, grating code disks need to reflect the light emitted by the light source. Once the reflective area is contaminated with dust or oil, the reflective performance will decrease. Therefore, grating code disks have high requirements for materials. Moreover, because grating code disks have high resolution, the material cost and processing cost of grating code disks are both high. On the other hand, mechanical code disks have lower requirements for materials and dust and oil resistance, but their resolution is lower. Summary of the Invention
[0003] This application provides a laser driving circuit, a lidar, and a storage medium, which can improve the resolution of a mechanical encoder without changing its existing structure or increasing the number of light-transmitting areas, and can reduce costs compared to a grating encoder.
[0004] In a first aspect, embodiments of this application provide an encoder pulse interpolation method. The encoder includes a mechanical code disk, a light source, and a photodetector. The mechanical code disk includes a light-transmitting area and a light-blocking area spaced circumferentially. The photodetector is capable of receiving light emitted by the light source and transmitted through the light-transmitting area to generate a corresponding pulse signal. The pulse signal includes multiple pulse cycles. The interpolation method includes the following steps:
[0005] The average rotational speed of the mechanical encoder within the pulse period to be interpolated is obtained, and the reference average rotational speed of the mechanical encoder within a reference duration is obtained, wherein the reference duration includes at least one of the pulse periods.
[0006] The insertion time interval for inserting rising edge pulses is determined based on the average rotational speed, the reference average rotational speed, and the target angular resolution.
[0007] Within the pulse period to be interpolated, the rising edge pulse is inserted into the pulse period at intervals of the insertion time interval, starting from the beginning of the pulse period to be interpolated.
[0008] Optionally, the step of determining the insertion time interval for inserting the rising edge pulse based on the average rotational speed, the reference average rotational speed, and the target angular resolution includes:
[0009] Obtain the absolute value of the difference between the average rotational speed and the reference average rotational speed;
[0010] When the absolute value of the difference is less than a first preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotation speed.
[0011] Optionally, the step of determining the insertion time interval for inserting the rising edge pulse based on the average rotational speed, the reference average rotational speed, and the target angular resolution includes:
[0012] Obtain the absolute value of the difference between the average rotational speed and the reference average rotational speed;
[0013] When the absolute value of the difference is greater than a first preset value and less than or equal to a second preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotation speed.
[0014] Wherein, the second preset value is greater than the first preset value, and the second preset value is determined based on the average rotational speed, the reference average rotational speed, and the angular resolution of the mechanical encoder.
[0015] Optionally, after the step of obtaining the absolute value of the difference between the average rotational speed and the reference average rotational speed, the method further includes:
[0016] When the absolute value of the difference is greater than the second preset value, the pulse period to be interpolated is taken as the pulse period to be determined.
[0017] Obtain the total duration of multiple consecutive undetermined pulse periods;
[0018] When the total duration is less than the first preset duration, the rising edge pulse is not inserted into the undetermined pulse period;
[0019] When the total duration exceeds the first preset duration, the average rotation speed of the mechanical encoder within the total duration is updated to the reference average rotation speed.
[0020] The insertion time interval for inserting rising edge pulses is determined based on the average rotational speed, the reference average rotational speed, and the target angular resolution.
[0021] Optionally, the pulse period to be interpolated is the pulse period most recently output by the photodetector, and the reference duration includes at least one pulse period preceding the pulse period to be interpolated; or, the reference duration includes a plurality of consecutive pulse periods with a total duration greater than a second preset duration, and the plurality of consecutive pulse periods includes the pulse period to be interpolated.
[0022] Optionally, the light source includes a light-emitting diode (LED), the photodetector includes a phototransistor, and the encoder further includes a first current-limiting resistor and a second current-limiting resistor. The anode of the LED is connected to an external power supply via the first current-limiting resistor, the cathode of the LED is grounded, the base of the phototransistor is used to receive the light emitted by the LED, the collector of the phototransistor is connected to an external power supply via the second current-limiting resistor and is used to output the pulse signal, and the emitter of the phototransistor is grounded.
[0023] Optionally, the encoder further includes a first capacitor and a second capacitor connected in parallel, one of the parallel terminals of the first capacitor and the second capacitor being connected to the anode of the light-emitting diode via the first current-limiting resistor, and the other parallel terminal of the first capacitor and the second capacitor being grounded.
[0024] Optionally, the encoder further includes a hysteresis comparator, which includes a comparator and a feedback resistor. One end of the feedback resistor is connected to the output terminal of the comparator, and the other end of the feedback resistor is connected to the non-inverting input terminal of the comparator and to the collector of the phototransistor. The inverting input terminal of the comparator is used to connect to a reference comparison voltage.
[0025] Optionally, the encoder further includes a pull-down resistor and a third capacitor connected in parallel. One of the parallel terminals of the pull-down resistor and the third capacitor is connected to the inverting input of the comparator to input the reference comparison voltage to the inverting input. The other parallel terminal of the pull-down resistor and the third capacitor is grounded.
[0026] Secondly, embodiments of this application provide a lidar, including:
[0027] Brushless motor;
[0028] The encoder has a mechanical code disk that is fitted onto the shaft of the brushless motor to rotate with the shaft of the brushless motor.
[0029] Storage medium for storing computer programs; and
[0030] A processor, connected to the memory, is configured to invoke the computer program to perform the interpolation method as described in any of the preceding items.
[0031] Thirdly, embodiments of this application provide a storage medium storing a computer program, the computer program including program instructions, which, when executed by a processor, perform the interpolation method as described in any of the preceding claims.
[0032] Based on the encoder pulse interpolation method, lidar, and storage medium provided in this application, the average rotational speed of the mechanical code disk within the pulse period to be interpolated and the reference average rotational speed of the mechanical code disk within a reference duration are obtained. Then, the insertion time interval for inserting rising edge pulses is determined according to the average rotational speed, the reference average rotational speed, and the target angular resolution. Finally, within the pulse period to be interpolated, the rising edge pulse is inserted into the pulse period to be interpolated at intervals of the insertion time interval from the start time point of the pulse period to be interpolated. Therefore, the resolution of the mechanical encoder can be improved without changing the existing structure of the mechanical encoder, i.e., without increasing the number of light-transmitting areas, and the cost can be reduced compared to the grating encoder. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 This is a schematic diagram of the structure of a mechanical encoder in one embodiment of this application;
[0035] Figure 2 This is a flowchart illustrating an encoder pulse interpolation method in one embodiment of this application;
[0036] Figure 3 This is a flowchart illustrating step S20 in one embodiment of this application;
[0037] Figure 4 This is a flowchart illustrating step S20 in another embodiment of this application;
[0038] Figure 5 This is a circuit diagram of an encoder in one embodiment of this application;
[0039] Figure 6 This is a schematic diagram of the structure of a computer device according to one embodiment of this application. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0041] Where the following description relates to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0042] In the description of this application, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances. Furthermore, in the description of this application, unless otherwise stated, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0044] In related technologies, the stator and rotor of a brushless motor are not in contact. Compared to brushed motors, the rotor position of a brushless motor cannot be directly obtained. Therefore, an encoder is needed to measure the current position of the rotor in the brushless motor. To improve the detection resolution, grating encoders are generally used in related technologies. Grating encoders employ a reflective structure and typically include a light source, a photosensitive element, and a grating disk. The grating disk has reflective gratings spaced circumferentially and through holes between gratings. The number of gratings determines the resolution of the grating encoder. For example, if the grating disk has 3000 gratings arranged axially, then the resolution of the grating encoder is 360° / 3000, which equals 0.12 degrees. The grating disk is mounted on the shaft of the brushless motor and rotates with it. The light source and the photosensitive element are located on the same side of the grating disk. Every time the grating disk rotates 0.12°, the light emitted by the light source is reflected once by the grating and received by the photosensitive element on the same side, which then outputs a corresponding pulse signal, thereby detecting the rotor position, i.e., the position of the brushless motor. The advantage of grating encoders is their high resolution. Because of the requirement for high resolution, as many very fine gratings as possible need to be set on the grating disk. Therefore, the manufacturing cost of the grating disk is significantly higher. The grating cannot have too much dust or oil, otherwise the reflectivity of the grating will decrease. Therefore, the grating disk also has special material requirements, leading to increased material costs.
[0045] To address the high cost issue of grating encoders, this application employs a mechanical encoder. The mechanical encoder utilizes a light-transmitting structure, such as... Figure 1The diagram shows a structural schematic of a mechanical code disk 100. The mechanical encoder includes a mechanical code disk 1, a light source 2, and a light detection element 3. The mechanical code disk includes multiple light-transmitting areas 5 and multiple light-blocking areas 4 spaced circumferentially. The light source 2 and the light detection element 3 are located on opposite sides of the mechanical code disk. The mechanical code disk is mounted on the shaft of a brushless motor and rotates with the shaft. During the rotation of the mechanical code disk, the light emitted by the light source 2 can pass through the light-transmitting areas 5, but is also blocked by the light-blocking areas 4. The light detection element 3 can receive the light emitted by the light source 2 that passes through the light-transmitting areas 5 and generate a corresponding rising edge signal. When the light detection element 3 does not receive the light emitted by the light source 2, it means that the light emitted by the light source 2 is blocked by the light-blocking areas 4, and the light detection element 3 generates a falling edge signal. As the mechanical code disk rotates, the light detection element 3 continuously generates rising edge signals and falling edge signals alternately, thereby forming a pulse signal and outputting it. One rising edge signal and the immediately following falling edge signal are defined as one pulse cycle, and vice versa. Obviously, the pulse signal includes multiple pulse cycles. The position of the rotor, i.e., the brushless motor, can be obtained based on the pulse signal. Because mechanical encoders use a light-transmitting structure, they do not require expensive reflective materials or excellent reflectivity, resulting in lower material costs and better dust and oil resistance. To further reduce costs, the number of light-transmitting areas 5 on the mechanical code disk of a mechanical encoder is generally small. For example, if the number of light-transmitting areas 5 is 30, the angular resolution of the mechanical encoder is 360° / 30 = 12 degrees, which is low and leads to reduced position detection accuracy. Specifically, the light detection element 3 can be any photosensitive transistor, such as a photodiode, phototransistor, or photofield-effect transistor.
[0046] To address the low resolution issue of mechanical encoders, the first aspect of this application provides an interpolation method for mechanical encoder pulses. This method improves the resolution of mechanical encoders without altering their existing structure or increasing the number of light-transmitting areas. The resolution can reach or even exceed that of grating encoders. Specifically, the encoder pulse interpolation method of this application can be applied to any product with a brushless motor that requires position detection, including but not limited to LiDAR. The following explanation uses the application of this encoder pulse interpolation method to LiDAR as an example. Please refer to [link to relevant documentation]. Figure 2 The encoder pulse interpolation method includes the following steps:
[0047] S10, obtain the average rotational speed of the mechanical encoder within the pulse period to be interpolated, and obtain the reference average rotational speed of the mechanical encoder within a reference duration, the reference duration including at least one pulse period.
[0048] In this embodiment, since the mechanical encoder disk rotates following the shaft of the brushless motor, the photodetector generates a corresponding pulse signal based on whether it detects light emitted from the light source. The pulse signal includes multiple pulse cycles. The interpolation method of this embodiment can interpolate any pulse cycle of the pulse signal. Interpolation can be understood as inserting rising edge pulses into a selected pulse cycle, with one rising edge pulse corresponding to one position of the brushless motor. This improves the resolution of the mechanical encoder disk from a software or algorithmic perspective.
[0049] After acquiring the pulse signal, the pulse period in the pulse signal can be interpolated. For example, in terms of timing, starting from the first pulse period of the pulse signal, each pulse period can be interpolated sequentially, that is, all pulse periods of the pulse signal are used as the pulse period to be interpolated in sequence; or, the required pulse period can be selected, and only the selected pulse period can be interpolated, that is, the selected pulse period can be used as the pulse period to be interpolated; or, the latest acquired pulse period can be acquired and used as the pulse period to be interpolated. In this embodiment, there are no specific restrictions on how the pulse period to be interpolated is selected.
[0050] It's understandable that a brushless motor has a preset speed for each pulse cycle, so this preset speed can be used as the average speed of the pulse cycle to be interpolated. Alternatively, the actual speed of the brushless motor can be monitored in real time, and the average speed of the mechanical encoder within the pulse cycle to be interpolated can be obtained based on the actual speed.
[0051] Specifically, the reference duration includes at least one pulse period. For example, the reference duration may include any pulse period other than the pulse period to be interpolated, or it may include multiple consecutive pulse periods, or it may include discontinuous pulse periods. This embodiment does not limit this. The average rotational speed within the reference duration is the reference average rotational speed. The method for obtaining the reference average rotational speed can be similar to the method for obtaining the average speed described above, and will not be repeated here.
[0052] S20, determine the insertion time interval for inserting rising edge pulses based on the average rotational speed, the reference average rotational speed, and the target angular resolution.
[0053] In this embodiment, the target angular resolution is the desired angular resolution. Following the previous example, when the number of brushes in the light-transmitting area is 30, the mechanical encoder's angular resolution is 360° / 30 = 12 degrees, which is relatively low. Assuming that after interpolating the pulse period of the pulse signal using an interpolation method, a resolution of 0.1° is desired, then this 0.1° is the target angular velocity resolution. It is understood that the target angular velocity resolution is preset and can be adjusted according to actual conditions.
[0054] Specifically, the insertion time interval for inserting rising edge pulses can be determined based on the absolute value of the difference between the average rotational speed and the reference average rotational speed, as well as the target angular resolution, as detailed below. It is understandable that the higher the target angular resolution, the shorter the insertion time interval. For example, with the same brushless motor speed, if the original angular resolution of the mechanical encoder is 12°, to achieve a target angular velocity resolution of 0.1°, a rising edge pulse must be inserted every 0.1° of rotation. To achieve a target angular velocity resolution of 0.2°, a rising edge pulse must be inserted every 0.2° of rotation. At the same rotational speed, the insertion time interval for 0.1° is significantly shorter than that for 0.2°.
[0055] S30, within the pulse period to be interpolated, a rising edge pulse is inserted into the pulse period to be interpolated at intervals of one interpolation time interval, starting from the beginning time of the pulse period to be interpolated.
[0056] In this embodiment, when interpolating the pulse to be interpolated, starting from the beginning time point of the pulse period to be interpolated, i.e., the zero point of the pulse period, rising edge pulses are inserted into the pulse period at intervals of one interpolation time interval. Each rising edge pulse corresponds to a position in the brushless motor's rotation process. It can be understood that the pulse period before interpolation has only one rising edge pulse, while the pulse period after interpolation has multiple rising edge pulses, corresponding to multiple positions in the brushless motor's rotation process. That is, the resolution of the original output pulse signal of the mechanical encoder is improved to the target angular velocity resolution. The specific value of the target angular velocity resolution can be set according to actual needs. In summary, the interpolation method can improve the resolution of mechanical encoders and can reach or even exceed that of grating encoders.
[0057] When brushless motors with mechanical encoders are applied to LiDAR, especially for vehicle-mounted LiDAR, vehicles are in different driving states at different times. For example, a vehicle can travel at a near-constant speed on a straight road, at which point the brushless motor can rotate at a constant speed. However, vehicles also experience acceleration, deceleration, going uphill, going downhill, and vibrations caused by crossing obstacles. In these situations, the speed of the brushless motor will change due to the vehicle's driving state, and it cannot achieve or approach a constant speed.
[0058] To determine the impact of the current vehicle's driving state on the brushless motor's speed, in some embodiments, the pulse period to be interpolated is the most recently output pulse period of the photodetector. The reference duration includes at least one pulse period preceding the pulse period to be interpolated. That is, when the brushless motor is in operation, to more accurately obtain the current position of the brushless motor, the most recently output pulse period is used as the pulse period to be interpolated, and the reference duration includes one or more consecutive historical pulse periods closest to the most recently output pulse period. For example, according to the chronological order, the pulse signal includes a first pulse period, a second pulse period, a third pulse period, a fourth pulse period, a fifth pulse period, and a sixth pulse period. The most recently output pulse period is the sixth pulse period, so the reference duration includes at least the fifth pulse period. Of course, it can also include the fifth pulse period and the fourth pulse period, or it can include the fifth pulse period, the fourth pulse period, and the third pulse period, and so on. By using one or more consecutive historical pulse periods closest to the most recently output pulse period as a reference duration and obtaining the reference average velocity within that reference duration, the absolute value of the difference between the average velocity of the pulse period to be interpolated and the reference average velocity of the nearest historical pulse period can be more accurately reflected. This allows for a more accurate determination of whether to interpolate into the pulse period to be interpolated, thereby improving the accuracy of interpolation. This will be detailed below.
[0059] In other embodiments, the reference duration includes multiple consecutive pulse periods with a total duration greater than a second preset duration, and these multiple consecutive pulse periods include the pulse period to be interpolated. That is, the reference duration includes the pulse period to be interpolated and other pulse periods that are temporally continuous with the pulse period to be interpolated. Obtaining the reference average velocity corresponding to this reference duration can more accurately reflect the absolute value of the difference between the average velocity of the pulse period to be interpolated and the reference average velocity within the reference duration (a time period longer than a single pulse period), thereby more accurately determining whether to interpolate into the pulse period to be interpolated, and thus improving the accuracy of interpolation. It is understood that the pulse signal includes multiple different reference durations, each reference duration being a time period. Different time periods can be independent of each other, meaning that different time periods do not share pulse periods; different time periods can also partially overlap, meaning that different time periods may include shared pulse periods.
[0060] Depending on the different reference durations, please refer to the following embodiments: Figure 3 Step S20 includes:
[0061] S21, obtain the absolute value of the difference between the average speed and the reference average speed.
[0062] Specifically, the average speed is the average speed within the pulse period to be interpolated, and the reference average speed is the average speed within a reference duration. When the reference duration includes at least one pulse period preceding the pulse period to be interpolated, the reference average speed is the historical average speed prior to the pulse period to be interpolated. When the reference duration includes multiple consecutive pulse periods with a total duration greater than a second preset duration, the reference average speed is the average speed within the time period of the pulse period to be interpolated. The absolute value of the difference between the average rotational speed and the reference average rotational speed is the absolute value of the difference obtained by subtracting the reference average speed from the average speed.
[0063] S22, when the absolute value of the difference is less than the first preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotation speed.
[0064] Specifically, when the absolute value of the difference is less than the first preset value, it indicates that the average speed within the pulse period to be interpolated is not significantly different from the reference average speed within the reference duration. The vehicle is traveling at a straight and uniform speed or nearly straight and uniform speed according to the reference average speed. At this time, the insertion time interval is obtained based on the target angle resolution and the reference average speed. For example, when the reference average speed is 3000 rpm and the target angle resolution is 0.1°, the insertion time interval T1 = 0.1° / 3000 rpm = 0.1° / (50*360° / s) = 5.5555 us. That is, it takes 5.5555 us for the brushless motor to rotate 0.1°. Therefore, a rising edge pulse is inserted into the pulse period to be interpolated every 5.5555 us to improve the resolution.
[0065] In other embodiments, please refer to Figure 3 Step S20 includes:
[0066] S23, obtain the absolute value of the difference between the average speed and the reference average speed.
[0067] Similarly, the average speed is the average speed within the pulse period to be interpolated, and the reference average speed is the average speed within a reference duration. When the reference duration includes at least one pulse period preceding the pulse period to be interpolated, the reference average speed is the historical average speed prior to the pulse period to be interpolated; when the reference duration includes multiple consecutive pulse periods with a total duration greater than a second preset duration, the reference average speed is the average speed within the time period of the pulse period to be interpolated. The absolute value of the difference between the average rotational speed and the reference average rotational speed is the absolute value of the difference obtained by subtracting the reference average speed from the average speed.
[0068] S24, when the absolute value of the difference is greater than the first preset value and less than or equal to the second preset value, the insertion time interval is obtained according to the target angle resolution and the reference average rotation speed; wherein, the second preset value is greater than the first preset value, and the second preset value is determined according to the average rotation speed, the reference average rotation speed and the angle resolution of the mechanical encoder.
[0069] In this embodiment, the insertion time interval is obtained based on the target angular resolution and the reference average rotational speed. For example, when the reference average rotational speed is 3000 rpm and the target angular resolution is 0.1°, the insertion time interval T1 = 0.1° / 3000 rpm = 0.1° / (50*360° / s) = 5.5555 us. That is, it takes 5.5555 us for the brushless motor to rotate 0.1°. Therefore, a rising edge pulse is inserted into the pulse period to be interpolated every 5.5555 us to improve the resolution.
[0070] It should be noted that the above interpolation process needs to meet the following condition: the absolute value of the difference is greater than the first preset value and less than or equal to the second preset value. Under this condition, it indicates that the difference between the average speed within the pulse period to be interpolated and the reference average speed within the reference duration is larger than when the absolute value of the difference is less than the first preset value, but relatively accurate interpolation can still be achieved. Under this condition, within the pulse period to be interpolated, the vehicle may accelerate, decelerate, go uphill, go downhill, or vibrate due to crossing obstacles, resulting in a large difference between the average speed and the reference average speed. To ensure the accuracy of interpolation, that is, the accuracy of the correspondence between the inserted rising edge pulse and the actual position of the brushless motor, after determining the target angle resolution, the second preset value can be determined based on the average speed, the reference average speed, and the angle resolution of the mechanical encoder. The specific determination method is as follows:
[0071] Assuming the reference average speed ω is 3000 rpm, the target angular resolution β1 is 0.1°, and the mechanical encoder has 30 light-transmitting areas, then the angular resolution of the mechanical encoder is 360° / 30 = 12°. The second preset value is Δω. Under the premise that the target angular resolution β1 is 0.1°, considering the limiting state, that is, the absolute value of the difference between the average speed and the reference average speed ω is exactly equal to the second preset value Δω, i.e., average speed = second preset value Δω + reference average speed ω; then β1 = (Δω * β2) / (ω + Δω) = 0.1° = (Δω * 12°) / (3000 + Δω). Solving in reverse, we get the second preset value Δω ≈ 25. That is, when the absolute value of the difference is less than or equal to the second preset value, i.e., 25, by interpolating the pulse to be interpolated using the above interpolation method, it can be guaranteed that when a rising edge pulse is inserted every 5.5555 μs, the brushless motor will be at 5.5555 μs. The rotation angle of us is less than or equal to 0.1°, thus achieving the target angular velocity resolution and ensuring the accuracy of inserting rising edge pulses.
[0072] For further information, please refer to [link / reference]. Figure 4 After step S23, the interpolation method further includes:
[0073] S25, when the absolute value of the difference is greater than the second preset value, the pulse period to be interpolated is taken as the pulse period to be determined.
[0074] Specifically, when the absolute value of the difference is greater than the second preset value, it indicates that inserting a rising edge pulse into the pulse period to be interpolated will lead to inaccurate interpolation. Using the above example, if the absolute value of the difference is 30, which is greater than the second preset value of 25, the average speed is 2970 rpm or 3030 rpm. If a rising edge pulse is still inserted every 5.5555 μs, for an average speed of 2970 rpm, the brushless motor is rotating slower, but the insertion time interval remains unchanged, and the inserted rising edge pulse is 0.1° behind the corresponding rotation of the brushless motor. Conversely, for an average speed of 3030 rpm, the brushless motor is rotating faster, but the insertion time interval remains unchanged, and the inserted rising edge pulse is 0.1° behind the corresponding rotation of the brushless motor. That is, the inserted rising edge pulse does not accurately correspond to the position of the brushless motor during actual rotation. When the absolute value of the difference is greater than the second preset value, the pulse period to be interpolated is taken as the undetermined pulse period for subsequent step S26.
[0075] S26, obtain the total duration of multiple consecutive undetermined pulse cycles.
[0076] Specifically, a series of undetermined pulse periods refers to a series of undetermined pulse periods that are consecutive in time, where there are no pulse periods between them that meet the conditions for interpolation. The total duration is also the total duration of the series of undetermined pulse periods.
[0077] S27, when the total duration is less than the first preset duration, no rising edge pulse is inserted into the undetermined pulse period.
[0078] Specifically, when the total duration is less than the first preset duration, that is, when there is only one or a few consecutive pending pulse cycles, it indicates that the generation of the pending pulse cycle is triggered by a sudden event. The pulse cycle after one or a few pending pulse cycles can be interpolated. Therefore, rising edge pulses are not inserted into the pending pulse cycle to avoid inaccurate interpolation. The first preset duration can be set according to the actual situation.
[0079] S28, when the total duration exceeds the first preset duration, update the average rotation speed of the mechanical encoder within the total duration to the reference average rotation speed.
[0080] Specifically, when the total duration exceeds the first preset duration, it indicates that the speed of the brushless motor has changed over a longer period of time, rather than due to a sudden event. In this case, the average speed of the mechanical encoder over the total duration is updated to the reference average speed so that the insertion time interval can be re-determined.
[0081] S29, determine the insertion time interval for inserting rising edge pulses based on the average rotational speed, the updated reference average rotational speed, and the target angular resolution.
[0082] Specifically, the process of determining the insertion time interval for inserting the rising edge pulse based on the average rotational speed, the updated reference average rotational speed, and the target angular resolution is similar to the process described in steps S21-S25 above, and will not be repeated here. Redetermining the insertion time interval for inserting the rising edge pulse using the updated reference average rotational speed, average rotational speed, and target angular resolution can improve the accuracy of rising edge pulse insertion. Specifically, the new insertion time interval can be used to interpolate the pulse period to be determined, or it can be used to interpolate other non-determined pulse periods (such as pulse periods that meet the interpolation conditions after the total duration).
[0083] Please see Figure 5 Optionally, the light source includes a light-emitting diode (LED), and the photodetector includes a phototransistor. Figure 4U3 in the figure is a chip integrating an LED and a phototransistor. The mechanical encoder also includes a first current-limiting resistor R2 and a second current-limiting resistor R3. The anode of the LED is connected to the external power supply VCC-Encode via the first current-limiting resistor R2, thereby limiting the current input from the external power supply VCC-Encode to the LED to prevent excessive current from damaging the LED. The cathode of the LED is grounded. The base (not shown in the figure) of the phototransistor is used to receive the light emitted by the LED. The collector of the phototransistor is connected to the external power supply VCC-Encode via the second current-limiting resistor R3, thereby limiting the current input from the external power supply VCC-Encode to the phototransistor to prevent excessive current from damaging the phototransistor. The collector of the phototransistor is also used to output pulse signals. The emitter of the phototransistor is grounded. In addition, the first current-limiting resistor R2 and the second current-limiting resistor R3 can also play the role of impedance matching, so that the light-emitting diode and the phototransistor are in the conducting state.
[0084] Optionally, the mechanical encoder also includes a first capacitor C4 and a second capacitor C5 connected in parallel. One of the parallel terminals of the first capacitor C4 and the second capacitor C5 is connected to the anode of the light-emitting diode (LED) via a first current-limiting resistor R2, and the other parallel terminal of the first capacitor C4 and the second capacitor C5 is grounded. The parallel first capacitor C4 and the second capacitor C5 serve both as energy storage and filtering functions, used to filter out noise such as voltage spikes from the external power supply VCC-Encode input to the anode of the LED.
[0085] Optionally, the mechanical encoder also includes a hysteresis comparator, which comprises a comparator U1 and a feedback resistor R1. One end of the feedback resistor R1 is connected to the output of the comparator U1, and the other end is connected to the non-inverting input IN+ of the comparator U1 and then to the collector of the phototransistor. The inverting input IN- of the comparator U1 is used to connect a reference comparison voltage. The hysteresis comparator, consisting of the comparator U1 and the feedback resistor R1, can correct the pulse signal output from the phototransistor into a square wave, thus facilitating processing of the pulse signal by a subsequent processor such as an MCU.
[0086] Optionally, the mechanical encoder also includes a parallel pull-down resistor R10 and a third capacitor C7. One of the parallel terminals of the pull-down resistor R10 and the third capacitor C7 is connected to the inverting input terminal IN- of the comparator U1 and connected to the external power supply VCC-Encode to input a reference comparison voltage to the inverting input terminal IN-. The other parallel terminal of the pull-down resistor R10 and the third capacitor C7 is grounded. The pull-down resistor R10 is used to convert the voltage input from the external power supply VCC-Encode into the required voltage, i.e., the reference comparison voltage. The third capacitor C7 serves both as an energy storage device and as a filter, used to filter out noise such as voltage spikes from the external power supply VCC-Encode input to the inverting input terminal IN-, so as to make the reference comparison voltage more stable.
[0087] The second aspect of this application provides a lidar, which includes a brushless motor, a mechanical encoder as described in any of the above embodiments, a storage medium, and a processor. The mechanical encoder is mounted on the shaft of the brushless motor to rotate with the shaft. The storage medium is used to store a computer program. The processor is connected to the memory and is used to call the computer program to execute the interpolation method described in any of the above embodiments. Therefore, the lidar has the effects of the mechanical encoder and interpolation method described in any of the above embodiments, which will not be elaborated further here.
[0088] A third aspect of this application provides a storage medium storing a computer program, the computer program including program instructions, which, when executed by a processor, perform the interpolation method as described in any of the above embodiments.
[0089] Please see Figure 6 This document provides a schematic diagram of the structure of a computer device according to an embodiment of this application. Figure 6 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU or MCU, at least one network interface 1004, an input / output interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to enable communication between these components. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 5 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, an input / output interface module, and a content display application.
[0090] exist Figure 6In the computer device 1000 shown, the input / output interface 1003 is mainly used to provide an input interface for users and to obtain user input data.
[0091] In one embodiment, processor 1001 can be used to call the encoder pulse interpolation program stored in memory 1005, and specifically perform the following operations:
[0092] The average rotational speed of the mechanical encoder within the pulse period to be interpolated is obtained, and the reference average rotational speed of the mechanical encoder within a reference duration is obtained, wherein the reference duration includes at least one of the pulse periods.
[0093] The insertion time interval for inserting rising edge pulses is determined based on the average rotational speed, the reference average rotational speed, and the target angular resolution.
[0094] Within the pulse period to be interpolated, the rising edge pulse is inserted into the pulse period at intervals of the insertion time interval, starting from the beginning of the pulse period to be interpolated.
[0095] Optionally, when the processor 1001 determines the insertion time interval for inserting the rising edge pulse based on the average rotational speed, the reference average rotational speed, and the target angular resolution, it specifically performs the following operations:
[0096] Obtain the absolute value of the difference between the average rotational speed and the reference average rotational speed;
[0097] When the absolute value of the difference is less than a first preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotational speed.
[0098] Optionally, when the processor 1001 determines the insertion time interval for inserting the rising edge pulse based on the average rotational speed, the reference average rotational speed, and the target angular resolution, it specifically performs the following operations:
[0099] Obtain the absolute value of the difference between the average rotational speed and the reference average rotational speed;
[0100] When the absolute value of the difference is greater than a first preset value and less than or equal to a second preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotation speed.
[0101] Wherein, the second preset value is greater than the first preset value, and the second preset value is determined based on the average rotational speed, the reference average rotational speed, and the angular resolution of the mechanical encoder.
[0102] Optionally, after performing the step of obtaining the absolute value of the difference between the average rotational speed and the reference average rotational speed, the processor 1001 further performs the following operations:
[0103] When the absolute value of the difference is greater than the second preset value, the pulse period to be interpolated is taken as the pulse period to be determined.
[0104] Obtain the total duration of multiple consecutive undetermined pulse periods;
[0105] When the total duration is less than the first preset duration, the rising edge pulse is not inserted into the undetermined pulse period;
[0106] When the total duration exceeds the first preset duration, the average rotation speed of the mechanical encoder within the total duration is updated to the reference average rotation speed.
[0107] The insertion time interval for inserting rising edge pulses is determined based on the average rotational speed, the updated reference average rotational speed, and the target angular resolution.
[0108] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0109] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
[0110] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0111] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. An interpolation method of encoder pulses, characterized in that, The encoder includes a mechanical code disk, a light source, and a light detection element. The mechanical code disk includes light-transmitting areas and light-blocking areas spaced circumferentially. The light detection element can receive light emitted by the light source that passes through the light-transmitting areas to generate a corresponding pulse signal. The pulse signal includes multiple pulse cycles. The interpolation method includes the following steps: The average rotational speed of the mechanical encoder within the pulse period to be interpolated is obtained, and the reference average rotational speed of the mechanical encoder within a reference duration is obtained, wherein the reference duration includes at least one of the pulse periods. The insertion time interval for inserting rising edge pulses is determined based on the average rotational speed, the reference average rotational speed, and the target angular resolution. Within the pulse period to be interpolated, the rising edge pulse is inserted into the pulse period to be interpolated at intervals of the insertion time interval, starting from the beginning time of the pulse period to be interpolated. The step of determining the insertion time interval for inserting the rising edge pulse based on the average rotational speed, the reference average rotational speed, and the target angular resolution includes: Obtain the absolute value of the difference between the average rotational speed and the reference average rotational speed; When the absolute value of the difference is less than a first preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotation speed. When the absolute value of the difference is greater than a first preset value and less than or equal to a second preset value, the insertion time interval is obtained based on the target angle resolution and the reference average rotation speed. Wherein, the second preset value is greater than the first preset value, and the second preset value is determined based on the average rotational speed, the reference average rotational speed, and the angular resolution of the mechanical encoder. When the absolute value of the difference is greater than the second preset value, the pulse period to be interpolated is taken as the pulse period to be determined. Obtain the total duration of multiple consecutive undetermined pulse periods; When the total duration is less than the first preset duration, the rising edge pulse is not inserted into the undetermined pulse period; When the total duration exceeds the first preset duration, the average rotation speed of the mechanical encoder within the total duration is updated to the reference average rotation speed. The insertion time interval for inserting rising edge pulses is determined based on the average rotational speed, the reference average rotational speed, and the target angular resolution.
2. The interpolation method of claim 1, wherein, The pulse period to be interpolated is the most recently output pulse period of the photodetector. The reference duration includes at least one pulse period preceding the pulse period to be interpolated, or the reference duration includes a plurality of consecutive pulse periods with a total duration greater than a second preset duration, and the plurality of consecutive pulse periods includes the pulse period to be interpolated.
3. The interpolation method according to any one of claims 1-2, characterized in that, The light source includes a light-emitting diode (LED), the photodetector includes a phototransistor, and the encoder further includes a first current-limiting resistor and a second current-limiting resistor. The anode of the LED is connected to an external power supply via the first current-limiting resistor, the cathode of the LED is grounded, the base of the phototransistor is used to receive the light emitted by the LED, the collector of the phototransistor is connected to an external power supply via the second current-limiting resistor and is used to output the pulse signal, and the emitter of the phototransistor is grounded.
4. The interpolation method according to claim 3, characterized in that, The encoder also includes a first capacitor and a second capacitor connected in parallel. One of the parallel terminals of the first capacitor and the second capacitor is connected to the anode of the light-emitting diode via the first current-limiting resistor, and the other parallel terminal of the first capacitor and the second capacitor is grounded.
5. The interpolation method according to claim 3, characterized in that, The encoder also includes a hysteresis comparator, which includes a comparator and a feedback resistor. One end of the feedback resistor is connected to the output of the comparator, and the other end of the feedback resistor is connected to the non-inverting input of the comparator and to the collector of the phototransistor. The inverting input of the comparator is used to connect to a reference comparison voltage.
6. The interpolation method according to claim 5, characterized in that, The encoder also includes a pull-down resistor and a third capacitor connected in parallel. One of the parallel terminals of the pull-down resistor and the third capacitor is connected to the inverting input of the comparator to input the reference comparison voltage to the inverting input. The other parallel terminal of the pull-down resistor and the third capacitor is grounded.
7. A lidar, characterized in that, include: Brushless motor; The encoder as described in any one of claims 1-6, wherein the mechanical code disk is sleeved on the shaft of the brushless motor to rotate with the shaft of the brushless motor; Storage medium used to store computer programs; as well as A processor, connected to the memory, is configured to invoke the computer program to perform the interpolation method as described in any one of claims 1-6.
8. A storage medium, characterized in that, The storage medium stores a computer program, which includes program instructions that, when executed by a processor, perform the interpolation method as described in any one of claims 1-6.
Citation Information
Patent Citations
Method for increasing resolution ratio of absolute rotary encoder
CN103528612A
Multi-line laser radar system and horizontal mounting angle correction method thereof
CN107247268A