A method for determining motor speed and a driving device

By combining an encoder, a timer and a controller in the drive device, the number of pulses is obtained through periodic timing, which solves the problem of low measurement accuracy of low-digit encoders and achieves accurate calculation of motor speed and precise control of vehicle speed.

CN118249697BActive Publication Date: 2024-10-01FANJI TECH (SUZHOU) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410667082.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2024-10-01
Estimated Expiration
2044-05-28

Smart Images

  • Figure CN118249697B_ABST
    Figure CN118249697B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for determining the motor speed and a driving device. The method for determining the motor speed includes: when the encoder starts to run, the first timer periodically times from zero to a first preset duration according to a first cycle, and the second timer periodically times from zero to a second preset duration according to a second cycle; when the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the first continuous cycle value in which the rotation direction or pulse number of the motor does not change; when the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed; the controller determines the motor speed according to the rotation direction and the absolute value of the speed. The technical solution of the present invention improves the accuracy of the determination of the motor speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of motors, and in particular to a method for determining a motor speed and a driving device. Background Art

[0002] With the development of new energy technology, electric vehicles are becoming more and more widely used. In electric vehicles, the driver controls the motor to rotate, thereby driving the vehicle.

[0003] Some vehicles are based on speed control, that is, through the actual speed feedback of the motor, a speed command is generated to control the motor speed, thereby adjusting the vehicle speed. For example, through the proportional-integral controller, the actual speed of the motor is collected and input into the proportional-integral controller, which generates a corresponding voltage value according to the actual speed and the target speed, and transmits the generated voltage value to the motor to adjust the motor speed, thereby adjusting the vehicle speed.

[0004] Generally, the actual speed of the motor is obtained through an encoder. However, in order to reduce costs, an encoder with a relatively low bit number is generally used, that is, the binary bit number output by the encoder is relatively low, so the measurement accuracy of the encoder is low, and it is difficult to accurately measure the actual speed of the motor, which affects the speed control of the motor and makes it impossible to better control the speed of the vehicle. Summary of the invention

[0005] The present invention provides a method for determining the rotation speed of a motor and a driving device, so as to solve the problem that it is difficult to accurately measure the actual rotation speed of a motor by using an encoder with a relatively low number of bits.

[0006] According to one aspect of the present invention, a method for determining a motor speed is provided. The method for determining a motor speed is performed by a driving device of a motor, wherein the driving device comprises an encoder, a first timer, a second timer, and a controller; the controller is respectively connected to the encoder, the first timer, and the second timer; the method for determining a motor speed comprises:

[0007] When the encoder starts to run, the first timer periodically counts from zero to a first preset duration according to a first cycle, and the second timer periodically counts from zero to a second preset duration according to a second cycle;

[0008] When the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the first continuous period value in which the rotation direction or pulse number of the motor does not change according to the current first pulse number and the previous first pulse number at the end of the previous first cycle;

[0009] When the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed according to the current second pulse number, the first continuous cycle value and the target second pulse number at the end of the target second cycle; and sets the first continuous cycle value to zero; wherein the target second cycle is the second cycle in which the change in the previous pulse number is not zero;

[0010] The controller determines the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0011] Optionally, the controller determines the first continuous period value in which the rotation direction or pulse number of the motor does not change according to the current first pulse number and the previous first pulse number at the end of the previous first period, including:

[0012] If the current first pulse number is equal to the previous first pulse number, the controller determines that the first continuous period value corresponding to the current first period is the first continuous period value corresponding to the previous first period plus one;

[0013] If the pulse number corresponding to the current first cycle is different from the previous first pulse number, the controller determines that the first continuous period value corresponding to the current first cycle is zero, and determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number.

[0014] Optionally, the controller determines the absolute value of the rotation speed of the motor according to the current second pulse number, the first duration period value and the target second pulse number at the end of the target second period, including:

[0015] If the current second pulse number is equal to the previous second pulse number at the end of the previous second cycle, the controller adds one to the second continuous period value with no change in the pulse number, and when the second continuous period value at the end of the current second cycle is greater than the previous second continuous period value, the controller determines the absolute value of the rotation speed according to the second preset time length, the second continuous period value, the first continuous period value at the end of the target second cycle and the target second pulse number; wherein the previous second continuous period value is the second continuous period value at the beginning of the target second cycle;

[0016] If the current second pulse number is different from the previous second pulse number, the controller determines the absolute value of the rotational speed based on the first continuous period value at the end of the target second cycle, the first continuous period value at the end of the current second cycle, the second preset time length, and the pulse change between the current second pulse number and the target second pulse number; and sets the second continuous period value to zero.

[0017] Optionally, the controller determines the absolute value of the rotation speed according to the second preset time length, the second duration value, the first duration value at the end of the target second period, and the target second pulse number, including:

[0018] The controller adds the product of the second continuous period value and the second preset duration to the duration corresponding to the first continuous period value at the end of the target second period to obtain the target duration;

[0019] The controller determines the pulse change amount corresponding to the target second period according to the target second pulse number, and divides the number of revolutions corresponding to the pulse change amount corresponding to the target second period by the target duration to obtain the absolute value of the rotation speed.

[0020] Optionally, if the current second pulse number is equal to the previous second pulse number at the end of the previous second period, the controller adds one to the second continuous period value in which the pulse number does not change, and further includes:

[0021] When the second continuous period value at the end of the current second period is less than or equal to the previous second continuous period value, the absolute value of the rotation speed corresponding to the current second period is determined to be the absolute value of the rotation speed determined by the target second period.

[0022] Optionally, the controller determines the absolute value of the rotation speed according to the first continuous period value at the end of the target second period, the first continuous period value at the end of the current second period, the second preset time length, and the pulse change amount between the current second pulse number and the target second pulse number, including:

[0023] The controller obtains a time difference by adding the product of the second preset duration and the target value to the sum of the durations corresponding to the first duration value at the end of the target second cycle, and subtracting the duration corresponding to the first duration value at the end of the current second cycle; wherein the target value is the second duration value at the beginning of the current second cycle plus one;

[0024] The controller divides the number of revolutions corresponding to the pulse change between the current second pulse number and the target second pulse number by the time difference to obtain the absolute value of the rotation speed.

[0025] Optionally, the method further comprises:

[0026] If the second duration value reaches a preset threshold, the controller determines that the absolute value of the rotation speed is zero.

[0027] Optionally, the controller determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number, including:

[0028] The controller determines the changing direction of the pulse number according to the current first pulse number and the previous first pulse number;

[0029] The controller determines the rotation direction of the motor according to the change direction.

[0030] Optionally, the second preset duration is an integer multiple of the first preset duration.

[0031] According to another aspect of the present invention, a driving device is provided, the driving device is used to execute the motor speed determination method according to any embodiment of the present invention, the driving device comprises: an encoder, a first timer, a second timer and a controller; the controller is respectively connected to the encoder, the first timer and the second timer;

[0032] The encoder is used to output at least one pulse signal, and the controller is used to obtain the number of pulses of the pulse signal output by the encoder;

[0033] The first timer is used to periodically count from zero to a first preset duration according to a first cycle when the encoder starts to run, and the second timer is used to periodically count from zero to a second preset duration according to a second cycle when the encoder starts to run;

[0034] The controller is used to obtain the current first pulse number at the end of the current first cycle output by the encoder when the timing duration of the first timer reaches the first preset duration, and determine the first continuous period value in which the rotation direction or pulse number of the motor does not change according to the current first pulse number and the previous first pulse number at the end of the previous first cycle;

[0035] The controller is also used to obtain the current second pulse number at the end of the current second cycle output by the encoder when the timing duration of the second timer reaches the second preset duration, and determine the absolute value of the motor speed according to the current second pulse number, the first continuous period value and the target second pulse number at the end of the target second cycle; and set the first continuous period value to zero; wherein the target second cycle is the second cycle in which the change of the previous pulse number is not zero;

[0036] The controller is also used to determine the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0037] The technical solution of the embodiment of the present invention is that when the encoder starts to run, the first timer is periodically timed from zero to the first preset duration, and the second timer is periodically timed from zero to the second preset duration. When the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the rotation direction of the motor or the first continuous period value of the pulse number without change according to the current first pulse number and the previous first pulse number of the previous first cycle. When the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed according to the current second pulse number, the first continuous period value and the previous target second pulse number at the end of the previous target second cycle; or determines the absolute value of the speed according to the pulse change amount corresponding to the second cycle in which the previous pulse number changes to non-zero. In this way, when the motor speed is small and the pulse number changes slowly, by determining the first continuous period value of the pulse without change, the duration corresponding to the pulse change amount of the two cycles can be accurately calculated, and the absolute value of the motor speed can be accurately calculated. Moreover, when the pulse change amount in the current second cycle is zero, the absolute value of the speed will be determined according to the target second pulse number of the pulse change amount corresponding to the target second cycle in which the previous pulse number change is not zero, which can avoid the situation where the motor speed is small and the pulse number changes slowly, and when the pulse number does not change in a certain period of time, the motor speed is directly determined to be zero, thereby achieving the effect of accurately determining the absolute value of the motor speed. In addition, by setting the second timer, the absolute value of the motor speed can be calculated according to the pulse change amount before and after the end of the second cycle, and the number of pulses in the second cycle will not be too many, thereby avoiding the situation where the number of pulses is missed when the motor speed is high and the number of pulses changes quickly, thereby further improving the accuracy of the motor speed determination, which is conducive to achieving accurate control of the vehicle.

[0038] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0040] Figure 1 is a flow chart of a method for determining a motor speed provided by an embodiment of the present invention;

[0041] Figure 2is a flow chart of another method for determining motor speed provided by an embodiment of the present invention;

[0042] Figure 3 is a flow chart of another method for determining motor speed provided by an embodiment of the present invention;

[0043] Figure 4 is a schematic diagram of a pulse signal provided by an embodiment of the present invention;

[0044] Figure 5 is a flow chart of another method for determining motor speed provided by an embodiment of the present invention;

[0045] Figure 6 is a schematic diagram of a circuit structure of a driving device provided by an embodiment of the present invention;

[0046] Figure 7 It is a schematic diagram of a circuit structure of a vehicle provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0047] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0048] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0049] The motor can be used in a vehicle, such as an electric vehicle. The motor is driven by a driving device, which can be a driver. The driving device determines the target speed of the motor according to the target speed of the vehicle, generates a corresponding target voltage according to the target speed, transmits the target voltage to the motor, drives the motor to run, so that the motor runs according to the target speed, and the vehicle reaches the target speed. After the vehicle starts running, the actual speed of the motor can be periodically obtained. The driving device generates a voltage to the motor according to the actual speed and the target speed according to the proportional integral control strategy, and adjusts the speed of the motor to ensure that the actual speed of the motor reaches the target speed. When collecting the speed of the motor, an encoder can be used for collection. According to the pulse signal output by the encoder, the number of pulses corresponding to the pulse signal is obtained, and the actual speed of the motor can be calculated. However, in the related art, in order to reduce costs, an encoder with a relatively low bit number is generally used, that is, the binary bit number output by the encoder is low, then the measurement accuracy of the encoder is low, it is difficult to accurately measure the actual speed of the motor, thereby affecting the speed control of the motor, and then the speed of the vehicle cannot be well controlled.

[0050] In view of the above technical problems, an embodiment of the present invention provides a method for determining the speed of a motor, which is executed by a driving device of the motor, and the driving device includes an encoder, a first timer, a second timer and a controller; the controller is respectively connected to the encoder, the first timer and the second timer. Among them, the encoder is, for example, an orthogonal encoder, having two pulse channels, and can output two pulse signals with a phase difference of 90°. The first timer and the second timer can perform timing, and the first timer, the second timer and the controller can be integrated on a driving chip, or can be independent devices, which is not limited in this embodiment. By connecting the controller to the first timer and the second timer respectively, the controller can act according to the timing duration of the first timer and the second timer, so as to facilitate the determination of the speed of the motor, thereby better controlling the operation of the motor.

[0051] Figure 1 is a flow chart of a method for determining motor speed provided by an embodiment of the present invention, with reference to Figure 1 , the motor speed determination method includes:

[0052] S101. When the encoder starts to run, the first timer periodically counts from zero to a first preset duration according to a first cycle, and the second timer periodically counts from zero to a second preset duration according to a second cycle.

[0053] Specifically, after the motor starts running, the encoder starts running, and the first timer and the second timer start timing. The first timer is periodically timed from zero to the first preset duration, that is, the timing from zero to the first preset duration is a first cycle, and then the timing from zero to the first preset duration is the next first cycle, and so on is repeated to achieve periodic timing. Similarly, the second timer is periodically timed from zero to the second preset duration, that is, the timing from zero to the second preset duration is a second cycle, and then the timing from zero to the second preset duration is the next second cycle, and so on is repeated to achieve periodic timing. Wherein, for example, the first preset duration and the second preset duration are different, and the first preset duration is, for example, 100 microseconds, or 200 microseconds, or 300 microseconds, or other values, which are not limited in this embodiment. The second preset duration is, for example, 1 millisecond, or 2 milliseconds, or 3 milliseconds, or 5 milliseconds, which are not limited in this embodiment.

[0054] S102. When the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the first continuous period value in which the rotation direction of the motor or the pulse number does not change based on the current first pulse number and the previous first pulse number at the end of the previous first cycle.

[0055] Among them, the encoder can convert the displacement into a pulse signal output, and the output value is, for example, the number of transition edges (rising edge or falling edge) of the pulse waveform. The controller can obtain the number of transition edges, that is, the number of pulses. When the encoder is an orthogonal encoder with two pulse channels, the controller can determine the number of pulses based on the relationship between the transition edges output by the two pulse channels and the two pulse signals. For example, the two pulse signals are an A-phase pulse signal and a B-phase pulse signal. When the A-phase pulse signal leads the B-phase pulse signal, it can be counted up. Each time a transition edge of an A-phase pulse signal is captured, the number of pulses is increased by one, and each time a transition edge of a B-phase pulse signal is captured, the number of pulses is increased by one, thereby obtaining the number of pulses; when the A-phase pulse signal lags behind the B-phase pulse signal, it can be counted down. Each time a transition edge of an A-phase pulse signal is captured, the number of pulses is reduced by one, and each time a transition edge of a B-phase pulse signal is captured, the number of pulses is reduced by one, thereby obtaining the number of pulses. For example, if the encoder is a 64-bit encoder, the motor rotates one circle, and the A-phase pulse signal corresponds to 64 pulses, that is, 128 transition edges. Similarly, the B-phase pulse signal corresponds to 128 transition edges, which means a total of 256 transition edges. When counting up, it can be counted from 0 to 255 in a loop; when counting down, it can be counted from 255 to 0 in a loop.

[0056] Specifically, when the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder. For example, when the first timer reaches the first preset duration for the first time, the timing of a first cycle is completed, and the controller obtains the first pulse number output by the encoder, which is the first pulse number at the end of the first first cycle. For example, when the nth timing of the first timer reaches the first preset duration, the timing of the nth first cycle is completed, and the controller obtains the first pulse number output by the encoder, which is the first pulse number at the end of the nth first cycle. Wherein, n is an integer greater than or equal to 1. In this way, after each first cycle ends, the controller can obtain the first pulse number output by the encoder, thereby obtaining the first pulse number corresponding to the end of each first cycle.

[0057] After obtaining the current first pulse number, the controller can compare the current first pulse number with the previous first pulse number of the previous first period. If the current first pulse number is unchanged compared to the previous first pulse number, the first continuous period value of the unchanged pulse number can be determined. If the current first pulse number is changed compared to the previous first pulse number, the rotation direction of the motor can be determined according to the change direction of the first pulse number.

[0058] For example, if the current cycle is the n+1th cycle and the previous cycle is the nth cycle, then the current first pulse number is the first pulse number at the end of the n+1th first cycle, and the previous pulse number is the first pulse number at the end of the nth first cycle. By comparing the first pulse number at the end of the n+1th first cycle with the first pulse number at the end of the nth first cycle, the first continuous cycle value in which the rotation direction of the motor or the number of pulses does not change can be determined.

[0059] S103. When the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed based on the current second pulse number, the first continuous cycle value and the target second pulse number at the end of the target second cycle; and sets the first continuous cycle value to zero; wherein the target second cycle is the second cycle in which the change in the previous pulse number is not zero.

[0060] For example, if the number of pulses at the end of the first second cycle is a, the number of pulses at the end of the second second cycle is still a, and the number of pulses at the end of the third second cycle is b, then the second second cycle is the second cycle in which the pulse number changes to zero, and the previous second cycle in which the pulse number changes to non-zero is the first second cycle, that is, the target second cycle.

[0061] Specifically, when the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder. For example, when the first timing of the second timer reaches the second preset duration, the timing of a second cycle is completed, and the controller obtains the second pulse number output by the encoder, which is the second pulse number at the end of the first second cycle. For example, when the mth timing of the second timer reaches the second preset duration, the timing of the mth second cycle is completed, and the controller obtains the second pulse number output by the encoder, which is the first pulse number at the end of the mth first cycle. Wherein, m is an integer greater than or equal to 1. In this way, after each second cycle ends, the controller can obtain the second pulse number output by the encoder, thereby obtaining the corresponding second pulse number at the end of each second cycle.

[0062] After obtaining the current second pulse number, the controller can determine the absolute value of the motor speed according to the current second pulse number, the first continuous period value and the target second pulse number at the end of the target second period. According to the first continuous period value, the number of the first continuous period in which the pulse does not change can be determined, and the duration of the pulse without change can be calculated, so that the second preset duration can be subtracted from the duration corresponding to the first continuous period value (the duration of the pulse without change), which is convenient for subtracting the duration of the pulse without change after the last pulse in the current second period appears, so that the time between the current second pulse number and the target second pulse number can be accurately determined, and the absolute value of the speed can be calculated according to the pulse change amount of the current second pulse number and the previous second pulse number, and the time between the current second pulse number and the previous second pulse number. In this way, the duration corresponding to the pulse change amount of the two cycles can be accurately calculated, and the absolute value of the motor speed can be accurately calculated. And when the number of pulses does not change, the motor speed will not be directly determined to be zero, so as to achieve the effect of accurately determining the absolute value of the motor speed.

[0063] After obtaining the current second pulse number, the controller can determine whether the second pulse number of the current second cycle has changed relative to the second pulse number of the previous second cycle according to the current second pulse number. If there is no change, the pulse change amount corresponding to the target second cycle can be determined according to the target second pulse number to determine the absolute value of the speed. For example, the second pulse number after the end of the m+2 second cycle is c, and the second pulse number after the end of the previous second cycle (the m+1 second cycle) is also c, then the pulse change amount of the m+2 second cycle is zero. The second pulse number after the end of the m second cycle is d, d is not equal to c, and the pulse number of the m+1 second cycle changes, then the m+1 second cycle is the target second cycle, and the absolute value of the motor speed can be calculated according to the pulse change amount of the m+1 second cycle. In this way, when the pulse number of the current second cycle does not change, the absolute value of the motor speed can be calculated according to the target second pulse number of the target second cycle, which can avoid the situation where the motor speed is small and the pulse number changes slowly. When the pulse number does not change in a certain period of time, the motor speed is directly determined to be zero, and the absolute value of the motor speed is accurately determined.

[0064] In some other embodiments, the first timer can start from zero and count continuously, and the second timer can also start from zero and count continuously. When the timing duration of the first timer is an integer multiple of the first preset duration, the controller obtains the current first pulse number output by the encoder, and determines the rotation direction of the motor or the first continuous period value without change in the pulse number based on the current first pulse number and the previous first pulse number at the end of the previous first cycle. When the timing duration of the second timer is an integer multiple of the second preset duration, the controller obtains the current second pulse number output by the encoder, and determines the absolute value of the motor speed based on the current second pulse number, the first continuous period value and the target second pulse number at the end of the target second cycle. This embodiment does not limit this.

[0065] In addition, by setting a second timer, the absolute value of the motor speed can be calculated according to the pulse change before and after the end of the corresponding second cycle, so that the number of pulses in the second cycle will not be too many, avoiding the situation where the number of pulses is missed when the motor speed is high and the number of pulses changes rapidly, thereby further improving the accuracy of the motor speed determination, which is conducive to achieving accurate control of the vehicle.

[0066] Therefore, even if an encoder with a lower number of bits (i.e. an encoder with lower precision) is used, the accuracy of the motor speed determination can be guaranteed, and accurate control of the vehicle speed can be achieved while reducing costs.

[0067] Furthermore, when calculating the absolute value of the motor speed, the first continuous cycle value is set to zero, that is, at the end of each second cycle, the first continuous cycle value is set to zero, that is, in the second cycle, the first continuous cycle value can accumulate counts, and in different second cycles, the first continuous cycle value will not accumulate counts, so that the first continuous cycle value corresponding to each second cycle is independent of the first continuous cycle value corresponding to the previous second cycle, thereby avoiding errors in calculating the duration between pulses.

[0068] S104: The controller determines the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0069] Specifically, after controlling the rotation direction of the motor, the speed direction can be determined, and the speed of the motor can be determined according to the speed direction and the absolute value of the speed. In this way, it is convenient to control the operation of the motor according to the speed of the motor, so that the motor speed meets the requirements of the vehicle target speed.

[0070] The technical solution of this embodiment, when the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed according to the current second pulse number, the first continuous period value and the target second pulse number at the end of the target second cycle. In this way, when the motor speed is small and the pulse number changes slowly, by determining the first continuous period value when the pulse does not change, the duration corresponding to the pulse change amount of the two cycles can be accurately calculated, and the absolute value of the motor speed can be accurately calculated. Moreover, when the pulse change amount is zero in the current second cycle, the absolute value of the speed will be determined according to the target second pulse number corresponding to the target second cycle, which can avoid the situation where the motor speed is small, the pulse number changes slowly, and the motor speed is directly determined to be zero when the pulse number does not change in a certain period of time, and the effect of accurately determining the absolute value of the motor speed is achieved. In addition, by setting the second timer, the absolute value of the motor speed can be calculated according to the pulse change amount before and after the end of the second cycle in response to the pulse number, and the number of pulses in the second cycle will not be too much, avoiding the situation where the motor speed is high and the pulse number changes quickly, and the number of pulses is missed, thereby further improving the accuracy of the motor speed determination, which is conducive to the accurate control of the vehicle.

[0071] Based on the above technical solutions, Figure 2 is a flowchart of another method for determining the motor speed provided by an embodiment of the present invention. Optionally, refer to Figure 2 , the motor speed determination method includes:

[0072] S201. When the encoder starts to run, the first timer periodically counts from zero to a first preset duration according to a first cycle, and the second timer periodically counts from zero to a second preset duration according to a second cycle.

[0073] S202, when the timing duration of the first timer reaches the first preset duration, the controller determines whether the current first pulse number is equal to the previous first pulse number, if so, execute step S203; if not, execute step S204.

[0074] Specifically, the current first pulse number is the first pulse number at the end of the current first cycle, and the previous first pulse number is the first pulse number at the end of the previous first cycle. For example, if the current first cycle is the n+1th first cycle, then the current first pulse number is the first pulse number at the end of the n+1th first cycle, and the previous first pulse number is the first pulse number at the end of the nth first cycle. By comparing whether the current first pulse number is equal to the previous first pulse number, it can be determined whether the pulse change amount corresponding to the current first cycle is zero, that is, whether the pulse jump edge is captured in the current first cycle.

[0075] S203: The controller determines that the first continuous period value corresponding to the current first period is the first continuous period value corresponding to the previous first period plus one.

[0076] Specifically, if the current first pulse number is equal to the previous first pulse number, it indicates that there is no transition edge in the current first cycle, that is, the first pulse number has not changed, and the first continuous period value corresponding to the current first cycle is the first continuous period value corresponding to the previous first cycle plus 1. For example, if the first continuous period value at the end of the previous first cycle is Tsg, then the first continuous period value at the end of the current first cycle is Tsg+1.

[0077] Exemplarily, the current first cycle is the n+1th first cycle, the current first pulse number corresponding to the n+1th first cycle is f, the previous first cycle is the nth first cycle, the previous first pulse number corresponding to the nth first cycle is also f, and at the end of the nth first cycle, the first continuous cycle value is h, then the first continuous cycle value at the end of the n+1th first cycle is h+1.

[0078] S204, the controller determines that the first continuous period value corresponding to the current first period is zero, and determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number.

[0079] Specifically, if the current first pulse number is not equal to the previous pulse number, it indicates that a transition edge occurs in the current first period, that is, the first pulse number changes, and the first continuous period value is cleared.

[0080] The controller determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number. For example, the rotation direction of the motor can be determined according to the difference between the current first pulse number and the previous first pulse number, or the rotation direction of the motor can be determined according to the change direction of the current first pulse number relative to the previous first pulse number. In this way, it is easy to determine the rotation direction of the motor, thereby determining the rotation speed of the motor, and then controlling the operation of the motor. By determining the rotation direction of the motor according to the difference between the first pulse numbers of two adjacent first cycles, the rotation direction of the motor can be determined by using the minimum path without too much judgment, which is conducive to improving the efficiency of motor control.

[0081] S205. When the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed based on the current second pulse number, the first continuous cycle value and the target second pulse number at the end of the target second cycle; and sets the first continuous cycle value to zero; wherein the target second cycle is the second cycle in which the change in the previous pulse number is not zero.

[0082] S206. The controller determines the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0083] Based on the above technical solutions, Figure 3 is a flowchart of another method for determining the motor speed provided by an embodiment of the present invention. Optionally, refer to Figure 3 , the motor speed determination method includes:

[0084] S301: When the encoder starts to run, the first timer periodically counts from zero to a first preset duration according to a first cycle, and the second timer periodically counts from zero to a second preset duration according to a second cycle.

[0085] S302. When the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the first continuous period value in which the rotation direction of the motor or the pulse number does not change based on the current first pulse number and the previous first pulse number at the end of the previous first cycle.

[0086] S303, when the timing duration of the second timer reaches the second preset duration, the controller determines whether the current second pulse number is equal to the previous second pulse number at the end of the previous second cycle, if so, execute step S304; if not, execute step S305.

[0087] Specifically, the current second pulse number is the second pulse number at the end of the current second cycle, and the previous second pulse number is the second pulse number at the end of the previous second cycle. For example, if the current second cycle is the m+1th second cycle, the current second pulse number is the second pulse number at the end of the m+1th second cycle, and the previous second pulse number is the second pulse number at the end of the mth second cycle. By comparing whether the current second pulse number is equal to the previous second pulse number, it can be determined whether the pulse change amount corresponding to the current second cycle is zero.

[0088] S304, the controller adds one to the second continuous cycle value in which the number of pulses does not change, and when the second continuous cycle value at the end of the current second cycle is greater than the previous second continuous cycle value, the controller determines the absolute value of the rotational speed based on the second preset duration, the second continuous cycle value and the target second number of pulses; and sets the first continuous cycle value to zero; wherein the previous second continuous cycle value is the second continuous cycle value at the beginning of the target second cycle.

[0089] Specifically, if the current second pulse number is equal to the previous second pulse number, it indicates that there is no transition edge in the current second cycle, that is, the second pulse number has not changed, and there is no pulse in the current second cycle, then the second continuous period value corresponding to the current second cycle is the second continuous period value corresponding to the previous second cycle plus 1. For example, if the second continuous period value at the end of the previous second cycle is Tse, then the second continuous period value at the end of the current second cycle is Tse+1.

[0090] Exemplarily, the current second cycle is the m+1th second cycle, the current second pulse number corresponding to the m+1th second cycle is e, the previous second cycle is the mth second cycle, the previous second pulse number corresponding to the mth second cycle is also e, and at the end of the mth second cycle, the second continuous period value is g, then at the end of the m+1th second cycle, the second continuous period value is g+1.

[0091] For example, Figure 4 is a schematic diagram of a pulse signal provided by an embodiment of the present invention, such as Figure 4 As shown, T1 represents a first cycle, and T2 represents a second cycle. Figure 4 As shown, there is no pulse in the first second cycle, so the pulse number is 0, there is a pulse in the second second cycle, the pulse number is 2, no transition edge appears in the third second cycle, the fourth second cycle and the fifth second cycle, and a transition edge appears in the sixth second cycle. Then the second continuous cycle value at the end of the first second cycle is 1, the second continuous cycle value at the end of the second second cycle is 0, the second continuous cycle value at the end of the third second cycle is 1, the second continuous cycle value at the end of the fourth second cycle is 2, and the second continuous cycle value at the end of the fifth second cycle is 3.

[0092] For example, if the current second cycle is the fourth second cycle, and the target cycle is the second second cycle, then the last continuous cycle value is the second continuous cycle value at the beginning of the second second cycle (that is, at the end of the first second cycle). The second continuous cycle value at the end of the fourth second cycle is greater than the second continuous cycle value at the end of the second second cycle, that is, the second continuous cycle value at the end of the current second cycle is greater than the previous second continuous cycle value. This indicates that the second continuous cycle value corresponding to the current second cycle is greater than the second continuous cycle value of the last pulse, indicating that the motor speed may have changed and a speed calculation is required.

[0093] The controller determines the absolute value of the rotational speed according to the second preset duration, the second continuous cycle value and the target second pulse number. The time difference between the target second cycle and the current second cycle can be determined according to the second continuous cycle value and the second preset duration, that is, the time experienced from the target second cycle to the current second cycle can be determined. The pulse variation corresponding to the target cycle can be determined according to the target second pulse number, and the absolute value of the motor rotational speed can be determined according to the pulse variation and the time difference. In this way, when the motor rotational speed is small and the pulse variation corresponding to the current second cycle is zero, the motor rotational speed will not be directly determined to be zero, which is conducive to improving the accuracy of the motor rotational speed determination.

[0094] S305. The controller determines the absolute value of the rotational speed based on the first continuous period value at the end of the target second period, the first continuous period value at the end of the current second period, the second preset duration, and the pulse change between the current second pulse number and the target second pulse number; and sets the second continuous period value to zero; and sets the first continuous period value to zero.

[0095] Specifically, the duration of the pulse without change after the last pulse of the current second cycle can be calculated according to the first continuous period value at the end of the current second cycle. The duration of the pulse without change between the last pulse of the target second cycle and the end of the target second cycle can be calculated according to the first continuous period value at the end of the target second cycle. In this way, according to the duration of the pulse without change after the last pulse of the current second cycle, the duration of the pulse without change at the end of the target second cycle and the second preset duration, the duration between the last pulse of the target second cycle and the last pulse of the current second cycle can be determined, and then the absolute value of the speed can be calculated according to the pulse change amount. In this way, the duration corresponding to the pulse change amount can be accurately determined, so that the absolute value of the speed can be accurately determined, and precise control of the motor can be achieved.

[0096] Furthermore, because the current second pulse number is different from the previous second pulse number, the second continuous period value needs to be set to zero to facilitate subsequent recording of an accurate second continuous period value.

[0097] For example, Figure 4 As shown, for example, the current second cycle is the sixth second cycle, the target second cycle is the second second cycle, the current second pulse number is 4, and the target second pulse number is 2. The first continuous period value at the end of the target second cycle is T sg1 , is 2; the first continuous period value at the end of the current second period is T sg2 , is 1. In this way, the duration between the two pulses can be accurately determined according to the first duration value at the end of the current second cycle, the first duration value at the end of the target second cycle, the number of second cycles between the two pulses and the second preset duration, so that the absolute value of the rotation speed can be accurately determined to achieve precise control of the motor.

[0098] S306: The controller determines the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0099] Based on the above technical solution, optionally, if the current second pulse number is equal to the previous second pulse number at the end of the previous second period, the controller adds one to the second continuous period value in which the pulse number does not change, and further includes:

[0100] When the second continuous period value at the end of the current second period is less than or equal to the previous second continuous period value, the absolute value of the rotation speed corresponding to the current second period is determined to be the absolute value of the rotation speed determined by the target second period.

[0101] Specifically, when the second continuous period value at the end of the current second period is less than or equal to the previous second continuous period value, it is still impossible to determine whether the motor speed has changed. The absolute value of the speed corresponding to the current second period is still the absolute value of the speed determined when the pulse was captured before (target second period).

[0102] On the basis of the above technical solution, optionally, the controller determines the absolute value of the rotation speed according to the second preset duration, the second duration value, the first duration value at the end of the target second period, and the target second pulse number, including:

[0103] Step a1: The controller adds the product of the second duration value and the second preset duration to the duration corresponding to the first duration value at the end of the target second period to obtain the target duration.

[0104] For example, Figure 4 As shown, for example, the current second cycle is the fifth second cycle, and the second continuous cycle value Tse at the end of the fifth second cycle is 3. The product of the second continuous cycle value multiplied by the second preset duration Tspd is the duration of no pulse after the target second cycle. The first continuous cycle value at the end of the target second cycle is T sg1The duration corresponding to the first duration value at the end of the target second period is the first duration value at the end of the target second period multiplied by the first preset duration Tdm, which is T sg1 ×Tdm. In this way, we can get the target duration T=Tspd×Tse+T sg1 ×Tdm. Thus, the target time length from the last pulse of the target second cycle to the end of the current second cycle can be accurately determined, so as to accurately determine the motor speed at the end of the current second cycle.

[0105] Step a2: The controller determines the pulse change amount corresponding to the target second period according to the target second pulse number, and divides the number of revolutions corresponding to the pulse change amount corresponding to the target second period by the target duration to obtain the absolute value of the rotation speed.

[0106] Specifically, according to the target second pulse number at the end of the target second cycle and the second pulse number at the beginning of the target second cycle, the pulse change corresponding to the target second cycle can be calculated, and the corresponding number of turns can be obtained by dividing the pulse change by the maximum number of pulses. Among them, the maximum number of pulses is the number of pulses corresponding to one revolution of the motor. The maximum number of pulses can be determined according to the number of bits of the encoder. For example, if the encoder has two pulse channels and the encoder is 64 bits, then one pulse channel outputs 64 pulses for one revolution, that is, one pulse channel outputs 128 transition edges (number of pulses) for one revolution, and two pulse channels output 256 transition edges (number of pulses) for one revolution. Divide the calculated number of revolutions by the target duration to calculate the absolute value of the motor speed.

[0107] For example, if the pulse variation is Pm and the maximum number of pulses is P0, the number of turns is calculated as Combined with the target duration T calculated above, the absolute value of the motor speed is .

[0108] Optionally, the controller determines the absolute value of the rotation speed according to the first continuous period value at the end of the target second period, the first continuous period value at the end of the current second period, the second preset duration, and the pulse change amount between the current second pulse number and the target second pulse number, including:

[0109] Step b1, the controller obtains a time difference by adding the product of the second preset time length and the second continuous period value at the beginning of the current second period to the sum of the continuous periods corresponding to the first continuous period value at the end of the target second period, and subtracting the continuous period corresponding to the first continuous period value at the end of the current second period. The target value is the second continuous period value at the beginning of the current second period plus one.

[0110] Specifically, for example, a plurality of first cycles are included in a second cycle. The product of the second preset duration and the target value is added to the sum of the duration corresponding to the first continuous cycle value at the end of the target second cycle, and the duration between the last pulse in the target second cycle and the current second cycle can be calculated. Then, the duration corresponding to the first continuous cycle value at the end of the current second cycle is subtracted, and the duration after the last pulse in the current second cycle can be subtracted. In this way, the time difference obtained is the duration between the last pulse of the target second cycle and the last pulse of the current second cycle, which facilitates accurate calculation of the absolute value of the rotation speed.

[0111] Exemplarily, the current second cycle is the m+1th second cycle, and the target second cycle is the mth second cycle. The second continuous cycle value at the beginning of the current second cycle is 0, and the target value is 1. The first continuous cycle value at the end of the mth second cycle is, for example, Tsg(n), and the first continuous cycle value at the end of the m+1th second cycle is, for example, Tsg(n+1). The second preset duration is Tspd, and the first preset duration is Tdm. The duration corresponding to the first continuous cycle value at the end of the previous second cycle is Tdm×Tsg(n), and the duration corresponding to the first continuous cycle value at the end of the current second cycle is Tdm×Tsg(n+1). The time difference T'=Tspd×1+Tdm×Tsg(n)-Tdm×Tsg(n+1)=Tspd+Tdm×Tsg(n)-Tdm×Tsg(n+1).

[0112] For example, Figure 4 As shown, for example, the current second cycle is the sixth second cycle, the target second cycle is the second second cycle, the second duration value at the beginning of the current second cycle is 3, and the target value is 4. The first duration value at the end of the target second cycle is T sg1 , the first continuous period value at the end of the current second period is T sg2 Then the time difference T'=Tspd×4+Tdm×T sg1 -Tdm×T sg2 .

[0113] Step b2: The controller divides the number of revolutions corresponding to the pulse change between the current second pulse number and the target second pulse number by the time difference to obtain the absolute value of the rotation speed.

[0114] Specifically, the current second pulse number is subtracted from the target second pulse number to obtain the pulse change of the current second cycle. The pulse change is divided by the maximum pulse number P0 to obtain the corresponding number of turns. The obtained number of turns is divided by the time difference to obtain the absolute value of the speed. Exemplarily, for example, if the pulse change is Pmu (m+1), the absolute value of the speed Vspd = Pmu (m+1) ÷ (P0×T'). In this way, according to the duration (time difference) between the last pulse of the target second cycle and the last pulse of the current second cycle and the pulse change corresponding to the current second cycle, the absolute value of the motor speed can be accurately determined, which facilitates accurate control of the motor.

[0115] Based on the above technical solutions, Figure 5 is a flowchart of another method for determining the motor speed provided by an embodiment of the present invention. Optionally, refer to Figure 5 , the motor speed determination method includes:

[0116] S401: When the encoder starts to run, the first timer periodically counts from zero to a first preset duration according to a first cycle, and the second timer periodically counts from zero to a second preset duration according to a second cycle.

[0117] S402. When the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the first continuous period value in which the rotation direction of the motor or the pulse number does not change based on the current first pulse number and the previous first pulse number at the end of the previous first cycle.

[0118] S403, when the timing duration of the second timer reaches the second preset duration, the controller determines whether the current second pulse number is equal to the previous second pulse number at the end of the previous second cycle, if so, execute step S404; if not, execute step S407.

[0119] S404, the controller increases the second continuous period value with no change in the number of pulses by one, and determines whether the updated second continuous period value reaches a preset threshold value, if not, executing step S405; if yes, executing step S406.

[0120] Specifically, the preset threshold is, for example, 100, or 200, or 300, which is not limited in this embodiment. By judging whether the updated second continuous period value reaches the preset threshold, it can be judged whether the duration of the pulse variation being zero is long, thereby facilitating the determination of the absolute value of the motor speed.

[0121] S405. The controller determines the absolute value of the rotation speed according to the second preset time length, the second continuous period value and the target second pulse number; and sets the first continuous period value to zero; wherein the previous second continuous period value is the second continuous period value at the beginning of the target second period.

[0122] S406: The controller determines that the absolute value of the rotation speed is zero; and sets the first continuous period value to zero.

[0123] Specifically, when the updated second duration value reaches the preset threshold, it indicates that the duration of the pulse variation being zero is long, and it can be determined that the absolute value of the motor speed is zero. In this way, misjudgment can be avoided, which is conducive to improving the accuracy of determining the motor speed.

[0124] S407, the controller determines the absolute value of the rotational speed based on the first continuous period value at the end of the target second period, the first continuous period value at the end of the current second period, the second preset duration, and the pulse change between the current second pulse number and the target second pulse number; and sets the second continuous period value to zero; and sets the first continuous period value to zero.

[0125] S408. The controller determines the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0126] On the basis of the above technical solutions, optionally, the controller determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number, including:

[0127] Step c1, the controller determines the changing direction of the pulse number according to the current first pulse number and the previous first pulse number;

[0128] Step c2: The controller determines the rotation direction of the motor according to the change direction.

[0129] Specifically, the controller can determine the rotation direction of the motor according to the direction of change between the current first pulse number and the previous first pulse number. The controller can determine that the rotation direction of the motor is forward when the current first pulse number is an increase count compared to the previous first pulse number (i.e., the change direction is an increase direction); and determine that the rotation direction of the motor is reverse when the current first pulse number is a decrease count compared to the previous first pulse number (i.e., the change direction is a decrease direction). Alternatively, the controller can determine that the rotation direction of the motor is reverse when the current first pulse number is an increase count compared to the previous first pulse number; and determine that the rotation direction of the motor is forward when the current first pulse number is a decrease count compared to the previous first pulse number. It can be specifically determined based on the installation of the encoder, and this embodiment does not limit it.

[0130] The first pulse number can be the number of transition edges in the pulse signal. For example, if the encoder has 64 bits, that is, one output cycle can output 64 high levels and low levels, then one pulse signal corresponds to 128 transition edges, and two pulse signals correspond to 256 transition edges. The encoder can be an up-count, that is, periodically counting from 0 to 255, or a down-count, that is, periodically counting from 255 to 0. For example, if the previous first pulse number is 245 and the current first pulse number is 250, it is an up-count, and the direction of rotation of the motor is forward; if the previous first pulse number is 245 and the current first pulse number is 240, it is a down-count, and the direction of rotation of the motor is reverse. Or, for example, if the previous first pulse number is 245 and the current first pulse number is 250, it is an up-count, and the direction of rotation of the motor is reverse; if the previous first pulse number is 245 and the current first pulse number is 240, it is a down-count, and the direction of rotation of the motor is forward.

[0131] For example, if the previous first pulse number is 252 and the current first pulse number is 2, it is an increase count, and the motor's rotation direction is forward; if the previous first pulse number is 252 and the current first pulse number is 242, it is a decrease count, and the motor's rotation direction is reverse. Or, for example, if the previous first pulse number is 252 and the current first pulse number is 2, it is an increase count, and the motor's rotation direction is reverse; if the previous first pulse number is 252 and the current first pulse number is 242, it is a decrease count, and the motor's rotation direction is forward.

[0132] For example, if the previous first pulse number is 5 and the current first pulse number is 255, it is a down count, and the motor's rotation direction is forward; if the previous first pulse number is 5 and the current first pulse number is 15, it is an up count, and the motor's rotation direction is reverse. Or, for example, if the previous first pulse number is 5 and the current first pulse number is 255, it is a down count, and the motor's rotation direction is reverse; if the previous first pulse number is 5 and the current first pulse number is 15, it is an up count, and the motor's rotation direction is forward.

[0133] In this way, by comparing the current first pulse number with the previous first pulse number, the rotation direction of the motor can be determined with the minimum path, and large changes in the first pulse number exceeding the count of one circle can be avoided, thereby improving the accuracy of determining the rotation direction of the motor.

[0134] Optionally, the second preset duration is an integer multiple of the first preset duration. In this way, the second cycle includes multiple first cycles. It can be ensured that at the end of the second cycle, the first continuous period has been determined, so that the duration between the last pulses of the two second cycles can be accurately determined according to the first continuous period, so that the absolute value of the motor speed can be accurately determined. In addition, it can be ensured that after determining the absolute value of the motor speed, the direction of the motor speed has been determined, so that the motor speed can be determined according to the direction and the absolute value of the speed, that is, the actual speed of the motor can be determined, and then the motor can be controlled according to the actual speed and the target speed of the motor, so that the motor speed reaches the target speed, and then the vehicle speed reaches the target speed.

[0135] An embodiment of the present invention further provides a driving device, which is used to execute the motor speed determination method provided in any of the above embodiments. Figure 6 is a schematic diagram of a circuit structure of a driving device provided by an embodiment of the present invention, with reference to Figure 6 The driving device includes: an encoder 110, a first timer 120, a second timer 130 and a controller 140; the controller 140 is connected to the encoder 110, the first timer 120 and the second timer 130 respectively;

[0136] The encoder 110 is used to output at least one pulse signal, and the controller 140 is used to obtain the number of pulses of the pulse signal output by the encoder;

[0137] The first timer 120 is used to periodically time from zero to a first preset duration according to a first cycle when the encoder starts to run, and the second timer 130 is used to periodically time from zero to a second preset duration according to a second cycle when the encoder starts to run;

[0138] The controller 140 is used to obtain the current first pulse number at the end of the current first cycle output by the encoder 110 when the timing duration of the first timer 120 reaches the first preset duration, and determine the rotation direction or pulse of the motor according to the current first pulse number and the previous first pulse number at the end of the previous first cycle, for example, the pulse change amount is the first continuous cycle value without change in the pulse number;

[0139] The controller 140 is further configured to obtain the current second pulse number at the end of the current second cycle output by the encoder 110 when the timing duration of the second timer 130 reaches the second preset duration, and determine the absolute value of the motor speed according to the current second pulse number, the first continuous cycle value and the target second pulse number at the end of the target second cycle; and set the first continuous cycle value to zero; wherein the target second cycle is the second cycle in which the change in the previous pulse number is not zero;

[0140] The controller 140 is further configured to determine the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.

[0141] The technical solution of the embodiment of the present invention is that when the encoder 110 starts to run, the first timer 120 periodically times from zero to the first preset duration, and the second timer 130 periodically times from zero to the second preset duration. When the timing duration of the first timer 120 reaches the first preset duration, the controller 140 obtains the current first pulse number at the end of the current first cycle output by the encoder 110, and determines the rotation direction of the motor or the first continuous period value in which the pulse number does not change according to the current first pulse number and the previous first pulse number of the previous first cycle. When the timing duration of the second timer 130 reaches the second preset duration, the controller 140 obtains the current second pulse number at the end of the current second cycle output by the encoder 110, and determines the absolute value of the motor speed according to the current second pulse number, the first continuous period value and the previous target second pulse number at the end of the previous target second cycle; or determines the absolute value of the speed according to the pulse change amount corresponding to the second cycle in which the previous pulse number change is not zero. In this way, when the motor speed is relatively low and the pulse number changes slowly, by determining the first continuous period value in which the pulse does not change, the duration corresponding to the pulse change amount of the two cycles can be accurately calculated, and the absolute value of the motor speed can be accurately calculated. Moreover, when the pulse change amount is zero in the current second cycle, the absolute value of the speed will be determined according to the target second pulse number of the pulse change amount corresponding to the target second cycle in which the previous pulse number change is not zero, which can avoid the situation where the motor speed is relatively low and the pulse number changes slowly, and when the pulse number does not change in a certain period of time, the motor speed is directly determined to be zero, achieving the effect of accurately determining the absolute value of the motor speed. Moreover, by setting the second timer, the absolute value of the motor speed can be calculated according to the pulse change amount before and after the end of the second cycle in response, and the number of pulses in the second cycle will not be too much, avoiding the situation where the number of pulses is missed when the motor speed is high and the number of pulses changes rapidly, thereby further improving the accuracy of the motor speed determination, which is conducive to achieving accurate control of the vehicle.

[0142] An embodiment of the present invention further provides a vehicle, Figure 7 is a schematic diagram of a circuit structure of a vehicle provided by an embodiment of the present invention, with reference to Figure 7 The vehicle includes the driving device 100 and the motor 200 provided in any of the above embodiments, and the motor 200 is connected to the driving device 100. The vehicle is, for example, an electric vehicle, a non-road vehicle, or a road vehicle, and this embodiment is not limited thereto. Since it includes the driving device provided in any of the above embodiments, it has the same beneficial effects as the driving device in any of the above embodiments, and will not be described in detail here.

[0143] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0144] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for determining motor speed, It is characterized in that The method is performed by a driving device of a motor, the driving device comprising an encoder, a first timer, a second timer and a controller; The controller is connected to the encoder, the first timer and the second timer respectively; the method comprises: When the encoder starts to run, the first timer periodically counts from zero to a first preset duration according to a first cycle, and the second timer periodically counts from zero to a second preset duration according to a second cycle; When the timing duration of the first timer reaches the first preset duration, the controller obtains the current first pulse number at the end of the current first cycle output by the encoder, and determines the first continuous period value in which the rotation direction or pulse number of the motor does not change according to the current first pulse number and the previous first pulse number at the end of the previous first cycle; When the timing duration of the second timer reaches the second preset duration, the controller obtains the current second pulse number at the end of the current second cycle output by the encoder, and determines the absolute value of the motor speed according to the current second pulse number, the first continuous cycle value and the target second pulse number at the end of the target second cycle; and sets the first continuous cycle value to zero; wherein the target second cycle is the second cycle in which the change in the previous pulse number is not zero; The controller determines the speed of the motor according to the rotation direction and the absolute value of the speed; The controller determines the first continuous period value in which the rotation direction or pulse number of the motor does not change according to the current first pulse number and the previous first pulse number at the end of the previous first period, including: If the current first pulse number is equal to the previous first pulse number, the controller determines that the first continuous period value corresponding to the current first period is the first continuous period value corresponding to the previous first period plus one; If the number of pulses corresponding to the current first period is different from the previous first pulse number, the controller determines that the first continuous period value corresponding to the current first period is zero, and determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number; The controller determines the absolute value of the rotation speed of the motor according to the current second pulse number, the first duration period value and the target second pulse number at the end of the target second period, including: If the current second pulse number is equal to the previous second pulse number at the end of the previous second cycle, the controller adds one to the second continuous period value with no change in the pulse number, and when the second continuous period value at the end of the current second cycle is greater than the previous second continuous period value, the controller determines the absolute value of the rotation speed according to the second preset time length, the second continuous period value, the first continuous period value at the end of the target second cycle and the target second pulse number; wherein the previous second continuous period value is the second continuous period value at the beginning of the target second cycle; If the current second pulse number is different from the previous second pulse number, the controller determines the absolute value of the rotation speed according to the first continuous period value at the end of the target second period, the first continuous period value at the end of the current second period, the second preset time length, and the pulse change amount between the current second pulse number and the target second pulse number; and sets the second continuous period value to zero; If the second duration period value reaches a preset threshold, the controller determines that the absolute value of the rotation speed is zero; The controller determines the absolute value of the rotation speed according to the second preset time length, the second duration value, the first duration value at the end of the target second period, and the target second pulse number, including: The controller adds the product of the second continuous period value and the second preset duration to the duration corresponding to the first continuous period value at the end of the target second period to obtain the target duration; The controller determines the pulse change amount corresponding to the target second period according to the target second pulse number, and divides the number of revolutions corresponding to the pulse change amount corresponding to the target second period by the target duration to obtain the absolute value of the rotation speed; The controller determines the absolute value of the rotation speed according to the first continuous period value at the end of the target second period, the first continuous period value at the end of the current second period, the second preset time length, and the pulse change amount between the current second pulse number and the target second pulse number, including: The controller obtains a time difference by adding the product of the second preset duration and the target value to the sum of the durations corresponding to the first duration value at the end of the target second cycle, and subtracting the duration corresponding to the first duration value at the end of the current second cycle; wherein the target value is the second duration value at the beginning of the current second cycle plus one; The controller divides the number of revolutions corresponding to the pulse change between the current second pulse number and the target second pulse number by the time difference to obtain the absolute value of the rotation speed.

2. The method according to claim 1, It is characterized in that If the current second pulse number is equal to the previous second pulse number at the end of the previous second period, the controller adds one to the second continuous period value in which the pulse number does not change, and further includes: When the second continuous period value at the end of the current second period is less than or equal to the previous second continuous period value, the absolute value of the rotation speed corresponding to the current second period is determined to be the absolute value of the rotation speed determined by the target second period.

3. The method according to claim 1, It is characterized in that The controller determines the rotation direction of the motor according to the current first pulse number and the previous first pulse number, including: The controller determines the changing direction of the pulse number according to the current first pulse number and the previous first pulse number; The controller determines the rotation direction of the motor according to the change direction.

4. The method according to any one of claims 1 to 3, It is characterized in that The second preset time length is an integer multiple of the first preset time length.

5. A driving device, It is characterized in that The driving device is used to execute the motor speed determination method according to any one of claims 1 to 4, and the driving device comprises: an encoder, a first timer, a second timer and a controller; the controller is respectively connected to the encoder, the first timer and the second timer; The encoder is used to output at least one pulse signal, and the controller is used to obtain the number of pulses of the pulse signal output by the encoder; The first timer is used to periodically count from zero to a first preset duration according to a first cycle when the encoder starts to run, and the second timer is used to periodically count from zero to a second preset duration according to a second cycle when the encoder starts to run; The controller is used to obtain the current first pulse number at the end of the current first cycle output by the encoder when the timing duration of the first timer reaches the first preset duration, and determine the first continuous period value in which the rotation direction or pulse number of the motor does not change according to the current first pulse number and the previous first pulse number at the end of the previous first cycle; The controller is also used to obtain the current second pulse number at the end of the current second cycle output by the encoder when the timing duration of the second timer reaches the second preset duration, and determine the absolute value of the motor speed according to the current second pulse number, the first continuous period value and the target second pulse number at the end of the target second cycle; and set the first continuous period value to zero; wherein the target second cycle is the second cycle in which the change of the previous pulse number is not zero; The controller is also used to determine the rotation speed of the motor according to the rotation direction and the absolute value of the rotation speed.