Sinusoidal signal generation method, device, equipment and medium

文档序号:553675 发布日期:2021-05-14 浏览:16次 中文

阅读说明:本技术 一种正弦信号的生成方法、装置、设备及介质 (Sinusoidal signal generation method, device, equipment and medium ) 是由 李宇翔 于 2021-01-07 设计创作,主要内容包括:本申请公开了一种正弦信号的生成方法、装置、设备及介质,该方法包括:当接收到伺服驱动器获取目标正弦信号的触发指令时,则从正弦信号发生器自身调取预先所存储的预设正弦信号;预设正弦信号只记录有其在1/4采样周期内每一个采样点处所对应的正弦函数值;判断目标正弦信号的目标采样频率是否大于或等于预设正弦信号的预设采样频率;若是,则对预设正弦信号的采样点进行均匀采样,以得到目标正弦信号;若否,则利用泰勒级数在预设正弦信号的相邻两个采样点之间进行均匀插值,以得到目标正弦信号,并将目标正弦信号发送至伺服驱动器。通过该方法不仅能够减少对于正弦信号发生器存储空间的占用量,而且,还能够提高其输出正弦信号的精度与速度。(The application discloses a method, a device, equipment and a medium for generating a sinusoidal signal, wherein the method comprises the following steps: when a trigger instruction for acquiring a target sinusoidal signal by a servo driver is received, a pre-stored preset sinusoidal signal is called from a sinusoidal signal generator; the preset sinusoidal signal only records the corresponding sinusoidal function value of each sampling point in the 1/4 sampling period; judging whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal; if so, uniformly sampling points of the preset sinusoidal signal to obtain a target sinusoidal signal; if not, carrying out uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by utilizing the Taylor series to obtain a target sinusoidal signal, and sending the target sinusoidal signal to the servo driver. By the method, the occupied amount of the storage space of the sinusoidal signal generator can be reduced, and the accuracy and the speed of outputting the sinusoidal signal can be improved.)

1. A method for generating a sinusoidal signal, applied to a sinusoidal signal generator, comprising:

when a trigger instruction for acquiring a target sinusoidal signal by a servo driver is received, a pre-stored preset sinusoidal signal is called from the sinusoidal signal generator; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in a 1/4 sampling period;

judging whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal;

if the target sampling frequency is greater than or equal to the preset sampling frequency, uniformly sampling points of the preset sinusoidal signal to obtain the target sinusoidal signal, and sending the target sinusoidal signal to the servo driver;

if the target sampling frequency is smaller than the preset sampling frequency, carrying out uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using a Taylor series to obtain the target sinusoidal signal, and sending the target sinusoidal signal to the servo driver.

2. The generation method according to claim 1, wherein the process of uniformly sampling the sampling points of the preset sinusoidal signal to obtain the target sinusoidal signal comprises:

acquiring a first target ratio between the target sampling frequency and the preset sampling frequency;

and uniformly extracting first sampling points from the sampling points of the preset sinusoidal signal according to the first target ratio, and acquiring the target sinusoidal signal by using the first sampling points.

3. The generation method according to claim 2, characterized in that the mathematical expression of the first sampling point is:

sin(i'×N)%f0,i<f0

wherein i' is the serial number of the first sampling point,% represents the remainder, N is the target ratio, f0Is the preset sampling frequency.

4. The generation method according to claim 1, wherein the process of uniformly interpolating between two adjacent sampling points of the preset sinusoidal signal by using taylor series to obtain the target sinusoidal signal comprises:

acquiring a second target ratio between the target sampling frequency and the preset sampling frequency;

and on the basis of the Taylor series, uniformly inserting second sampling points with a second target ratio between two adjacent sampling points of the preset sinusoidal signal so as to obtain the target sinusoidal signal by using the sampling points of the preset sinusoidal signal and the second sampling points.

5. The generation method according to claim 4, characterized in that the mathematical expression of the second sampling point is:

sin(i)+j×K1×cos(i)-j×j×K2×sin(i);

in the formula, K1=2π/[f0×(N+1)],i is the serial number of the sampling point in the preset sinusoidal signal, and j is the serial number of the second sampling point inserted between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signal.

6. The generation method according to any one of claims 1 to 5, characterized by further comprising:

and storing the mapping relation between the sine function value of the preset sine signal at each sampling point and the corresponding sampling point in the sine signal generator in a table form in advance.

7. A sinusoidal signal generating device, applied to a sinusoidal signal generator, comprising:

the signal calling module is used for calling a pre-stored preset sinusoidal signal from the sinusoidal signal generator when a triggering instruction for acquiring a target sinusoidal signal by the servo driver is received; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in a 1/4 sampling period;

the signal judgment module is used for judging whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal;

the first sending module is used for uniformly sampling points of the preset sinusoidal signal to obtain the target sinusoidal signal and sending the target sinusoidal signal to the servo driver if the target sampling frequency is greater than or equal to the preset sampling frequency;

and the second sending module is used for performing uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using a Taylor series to obtain the target sinusoidal signal and sending the target sinusoidal signal to the servo driver if the target sampling frequency is less than the preset sampling frequency.

8. The generation apparatus according to claim 7, further comprising:

and the relation storage module is used for storing the mapping relation between the sine function value of the preset sine signal at each sampling point and the corresponding sampling point in the sine signal generator in a table form.

9. A sinusoidal signal generating device, comprising:

a memory for storing a computer program;

processor for implementing the steps of a method of generating a sinusoidal signal according to any one of claims 1 to 6 when executing said computer program.

10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of a method for generating a sinusoidal signal according to any one of claims 1 to 6.

Technical Field

The present invention relates to the field of digital signal technology, and in particular, to a method, an apparatus, a device, and a medium for generating a sinusoidal signal.

Background

At present, a servo driver generally uses a sinusoidal signal to trigger a servo motor to move, and since the servo driver cannot generate the sinusoidal signal, the servo driver generally obtains the sinusoidal signal from a sinusoidal signal generator to trigger the servo motor to move. In the prior art, if a sinusoidal signal generator is required to output a sinusoidal signal with a specific frequency, a corresponding calculation program is generally required to be stored in the sinusoidal signal generator. The sine signal generation method commonly used by the existing sine signal generator mainly comprises a table look-up method, a Taylor series expansion method and an iteration method.

The table look-up method is to store the sine function value needed in the signal generator in advance, and then to look up the sine function value of the sine signal with specific sampling frequency at each sampling point by the table look-up method to output the corresponding sine signal. Although this method has the advantages of fast speed and high precision of outputting the sine signal, it needs to occupy a large amount of storage space of the sine signal generator. The taylor series expansion method is a method of approximating a true sinusoidal signal by expanding a taylor series polynomial to output a sinusoidal signal of a specific frequency, but the method requires a long operation time and cannot meet the requirement of real-time property of an output signal. The iterative method calculates the sine function value of the sine signal with a specific sampling frequency at each sampling point by using a recursion formula, and because a large amount of error accumulation is generated in the recursion process, the iterative method cannot meet the requirement of the sine signal on the output precision.

Therefore, it is an urgent technical problem to be solved by those skilled in the art to provide a sinusoidal signal generation method to reduce the storage space occupation of the sinusoidal signal generator and to improve the accuracy and speed of the sinusoidal signal output by the sinusoidal signal generator.

Disclosure of Invention

In view of the above, the present invention provides a sinusoidal signal generating method, apparatus, device and medium, so as to reduce the storage space occupation of a sinusoidal signal generator and improve the accuracy and speed of outputting sinusoidal signals by the sinusoidal signal generator. The specific scheme is as follows:

a generation method of a sinusoidal signal is applied to a sinusoidal signal generator and comprises the following steps:

when a trigger instruction for acquiring a target sinusoidal signal by a servo driver is received, a pre-stored preset sinusoidal signal is called from the sinusoidal signal generator; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in a 1/4 sampling period;

judging whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal;

if the target sampling frequency is greater than or equal to the preset sampling frequency, uniformly sampling points of the preset sinusoidal signal to obtain the target sinusoidal signal, and sending the target sinusoidal signal to the servo driver;

if the target sampling frequency is smaller than the preset sampling frequency, carrying out uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using a Taylor series to obtain the target sinusoidal signal, and sending the target sinusoidal signal to the servo driver.

Preferably, the process of uniformly sampling the sampling points of the preset sinusoidal signal to obtain the target sinusoidal signal includes:

acquiring a first target ratio between the target sampling frequency and the preset sampling frequency;

and uniformly extracting first sampling points from the sampling points of the preset sinusoidal signal according to the first target ratio, and acquiring the target sinusoidal signal by using the first sampling points.

Preferably, the mathematical expression of the first sampling point is as follows:

sin(i'×N)%f0,i<f0

wherein i' is the serial number of the first sampling point,% represents the remainder, N is the target ratio, f0Is the preset sampling frequency.

Preferably, the process of performing uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using a taylor series to obtain the target sinusoidal signal includes:

acquiring a second target ratio between the target sampling frequency and the preset sampling frequency;

and on the basis of the Taylor series, uniformly inserting second sampling points with a second target ratio between two adjacent sampling points of the preset sinusoidal signal so as to obtain the target sinusoidal signal by using the sampling points of the preset sinusoidal signal and the second sampling points.

Preferably, the mathematical expression of the second sampling point is as follows:

sin(i)+j×K1×cos(i)-j×j×K2×sin(i);

in the formula, K1=2π/[f0×(N+1)],i is the serial number of the sampling point in the preset sinusoidal signal, and j is the serial number of the second sampling point inserted between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signal.

Preferably, the method further comprises the following steps:

and storing the mapping relation between the sine function value of the preset sine signal at each sampling point and the corresponding sampling point in the sine signal generator in a table form in advance.

Correspondingly, the invention also discloses a generating device of the sine signal, which is applied to a sine signal generator and comprises the following components:

the signal calling module is used for calling a pre-stored preset sinusoidal signal from the sinusoidal signal generator when a triggering instruction for acquiring a target sinusoidal signal by the servo driver is received; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in a 1/4 sampling period;

the signal judgment module is used for judging whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal;

the first sending module is used for uniformly sampling points of the preset sinusoidal signal to obtain the target sinusoidal signal and sending the target sinusoidal signal to the servo driver if the target sampling frequency is greater than or equal to the preset sampling frequency;

and the second sending module is used for performing uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using a Taylor series to obtain the target sinusoidal signal and sending the target sinusoidal signal to the servo driver if the target sampling frequency is less than the preset sampling frequency.

Preferably, the method further comprises the following steps:

and the relation storage module is used for storing the mapping relation between the sine function value of the preset sine signal at each sampling point and the corresponding sampling point in the sine signal generator in a table form.

Correspondingly, the invention also discloses a generating device of the sine signal, which comprises:

a memory for storing a computer program;

a processor for implementing the steps of a method of generating a sinusoidal signal as disclosed in the foregoing when executing said computer program.

Accordingly, the present invention also discloses a computer readable storage medium having stored thereon a computer program which, when being executed by a processor, realizes the steps of a method for generating a sinusoidal signal as disclosed in the foregoing.

Therefore, in the invention, when the sine signal generator receives a trigger instruction of the servo driver for acquiring the target sine signal, the pre-stored preset sine signal is called from the sine signal generator; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in the 1/4 sampling period; then, the sinusoidal signal generator judges whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal; if the target sampling frequency is greater than or equal to the preset sampling frequency, the sinusoidal signal generator can obtain a target sinusoidal signal with the sampling frequency being the target sampling frequency only by uniformly sampling the sampling points of the preset sinusoidal signal, and when the sinusoidal signal generator obtains the target sinusoidal signal, the target sinusoidal signal is sent to the servo driver; if the target sampling frequency is smaller than the preset sampling frequency, at the moment, the sinusoidal signal generator can utilize the Taylor series to perform uniform interpolation between two adjacent sampling points of the preset sinusoidal signal, so that the target sinusoidal signal with the sampling frequency as the target sampling frequency can be obtained, and when the sinusoidal signal generator obtains the target sinusoidal signal, the target sinusoidal signal can be sent to the servo driver. Obviously, because the sinusoidal signal has axial symmetry, the sinusoidal function value of the preset sinusoidal signal in the whole sampling period can be obtained only by storing the sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in 1/4 sampling periods in the sinusoidal signal generator, so that the space occupation of the sinusoidal signal generator can be remarkably reduced, and in the process of obtaining the target sinusoidal signal by using the method, because a large amount of calculation is not needed, the calculation error can not be generated, and the precision and the speed of the sinusoidal signal output by the sinusoidal signal generator can be remarkably improved by the method. Correspondingly, the device, the equipment and the medium for generating the sine signal have the beneficial effects.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

Fig. 1 is a flowchart of a method for generating a sinusoidal signal according to an embodiment of the present invention;

fig. 2 is a schematic flow chart illustrating a process of obtaining a sine function value at each sampling point of a preset sine signal in a complete sampling period according to an embodiment of the present invention;

fig. 3 is a schematic flow chart of when sampling points with an interval of N are extracted from a preset sinusoidal signal when a target sampling frequency of a target sinusoidal signal is less than a preset sampling frequency of the preset sinusoidal signal;

fig. 4 is a schematic flow chart of inserting N second sampling points between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signal when the target sampling frequency of the target sinusoidal signal is less than the preset sampling signal of the preset sinusoidal signal;

fig. 5 is a structural diagram of a sinusoidal signal generating apparatus according to an embodiment of the present invention;

fig. 6 is a block diagram of a sinusoidal signal generating apparatus according to an embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Referring to fig. 1, fig. 1 is a flowchart of a method for generating a sinusoidal signal according to an embodiment of the present invention, where the method includes:

step S11: when a trigger instruction for acquiring a target sinusoidal signal by a servo driver is received, a pre-stored preset sinusoidal signal is called from a sinusoidal signal generator;

the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in the 1/4 sampling period;

step S12: judging whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal;

step S13: if the target sampling frequency is greater than or equal to the preset sampling frequency, uniformly sampling points of a preset sinusoidal signal to obtain a target sinusoidal signal, and sending the target sinusoidal signal to a servo driver;

step S14: and if the target sampling frequency is less than the preset sampling frequency, performing uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using the Taylor series to obtain a target sinusoidal signal, and sending the target sinusoidal signal to the servo driver.

In the embodiment, a sinusoidal signal generating method is provided, by which the occupied amount of storage space of a sinusoidal signal generator can be reduced, and the accuracy and speed of sinusoidal signal output by the sinusoidal signal generator can be improved. Specifically, the method for generating the sinusoidal signal is described by taking a sinusoidal signal generator as an execution subject, and a sinusoidal function value corresponding to each sampling point of a preset sinusoidal signal in a 1/4 sampling period is stored in the sinusoidal signal generator in advance.

When the sine signal generator receives a trigger instruction of acquiring a target sine signal by the servo driver, the sine signal generator can call a pre-stored preset sine signal from the sine signal generator, and compares the target sampling frequency of the target sine signal with the pre-stored sampling frequency of the preset sine signal, if the target sampling frequency of the target sine signal is greater than or equal to the pre-stored sampling frequency of the preset sine signal, at the moment, the sine signal generator only needs to uniformly sample sampling points of the preset sine signal, and a sine function value corresponding to each sampling point of the target sine signal in the 1/4 sampling period can be obtained.

It can be understood that, because the sinusoidal signal has axial symmetry, the sinusoidal function value of the target sinusoidal signal in the whole sampling period can be obtained according to the corresponding sinusoidal function value of each sampling point in the 1/4 sampling period of the target sinusoidal signal, and thus the target sinusoidal signal with the target sampling frequency is obtained. When the sinusoidal signal generator generates a target sinusoidal signal with a sampling frequency of the target sampling frequency, the sinusoidal signal generator feeds the target sinusoidal signal back to the servo driver.

If the target sampling frequency of the target sinusoidal signal is less than the preset sampling frequency of the preset sinusoidal signal, the sinusoidal signal generator performs uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using the taylor series, so that a sinusoidal function value corresponding to each sampling point of the target sinusoidal signal in the 1/4 sampling period can be obtained. It is conceivable that, when the sine function value at each sampling point of the target sine signal in the 1/4 sampling period is obtained, the sine function value at each sampling point of the target sine signal in the entire sampling period is obtained, in which case, the sine signal generator obtains the target sine signal at the target sampling frequency. When the sinusoidal signal generator generates a target sinusoidal signal with a sampling frequency of the target sampling frequency, the sinusoidal signal generator feeds the target sinusoidal signal back to the servo driver.

Obviously, in the sinusoidal signal generating method provided in this embodiment, since the sinusoidal function value of the preset sinusoidal signal at each sampling point at the sampling period of 1/4 is only stored in the sinusoidal signal generator, the space occupation for the sinusoidal signal generator can be significantly reduced compared to the table lookup method in the prior art.

In addition, when the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal, the sinusoidal signal generator only needs to uniformly extract the sampling signals in the preset sinusoidal signal, and the target sinusoidal signal with the sampling frequency as the target sampling frequency can be obtained. Therefore, the calculation amount of the sinusoidal signal generator in the process of generating the target sinusoidal signal can be reduced, and the speed of the sinusoidal signal generator in the process of generating the target sinusoidal signal can be improved. And when the target sampling frequency of the target sinusoidal signal is less than the preset sampling frequency of the preset sinusoidal signal, the sinusoidal signal generator can acquire the target sinusoidal signal with the sampling frequency as the target sampling frequency only by performing uniform interpolation between two adjacent sampling points of the preset sinusoidal signal according to the taylor series, so that compared with the prior art that the target sinusoidal signal with the sampling frequency as the target sampling frequency is acquired by simply using a taylor series expansion method, the method can achieve the purposes of reducing the calculation amount of the sinusoidal signal generator and improving the speed of the sinusoidal signal generator in generating the target sinusoidal signal. In summary, by the method for generating sinusoidal signals provided by the embodiment, not only can the space occupation amount of the sinusoidal signal generator be reduced, but also the precision and speed of the sinusoidal signal generator in outputting sinusoidal signals can be significantly improved.

It can be seen that, in this embodiment, when the sinusoidal signal generator receives a trigger instruction for the servo driver to acquire a target sinusoidal signal, a pre-stored preset sinusoidal signal is called from the sinusoidal signal generator; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in the 1/4 sampling period; then, the sinusoidal signal generator judges whether the target sampling frequency of the target sinusoidal signal is greater than or equal to the preset sampling frequency of the preset sinusoidal signal; if the target sampling frequency is greater than or equal to the preset sampling frequency, the sinusoidal signal generator can obtain a target sinusoidal signal with the sampling frequency being the target sampling frequency only by uniformly sampling the sampling points of the preset sinusoidal signal, and when the sinusoidal signal generator obtains the target sinusoidal signal, the target sinusoidal signal is sent to the servo driver; if the target sampling frequency is smaller than the preset sampling frequency, at the moment, the sinusoidal signal generator can utilize the Taylor series to perform uniform interpolation between two adjacent sampling points of the preset sinusoidal signal, so that the target sinusoidal signal with the sampling frequency as the target sampling frequency can be obtained, and when the sinusoidal signal generator obtains the target sinusoidal signal, the target sinusoidal signal can be sent to the servo driver. Obviously, because the sinusoidal signal has axial symmetry, the sinusoidal function value of the preset sinusoidal signal in the whole sampling period can be obtained only by storing the sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in 1/4 sampling periods in the sinusoidal signal generator, so that the space occupation of the sinusoidal signal generator can be remarkably reduced, and in the process of obtaining the target sinusoidal signal by using the method, because a large amount of calculation is not needed, the calculation error can not be generated, and the precision and the speed of the sinusoidal signal output by the sinusoidal signal generator can be remarkably improved by the method.

Based on the above embodiments, this embodiment further describes and optimizes the technical solution, and as a preferred implementation, the above steps: the process of uniformly sampling the sampling points of the preset sinusoidal signals to obtain the target sinusoidal signals comprises the following steps:

acquiring a first target ratio between a target sampling frequency and a preset sampling frequency;

and uniformly extracting first sampling points from the sampling points of the preset sinusoidal signal according to the first target ratio, and acquiring the target sinusoidal signal by using the first sampling points.

In this embodiment, a specific implementation manner is provided for a sinusoidal signal generator to generate a target sinusoidal signal, that is, in a process of uniformly sampling points of a preset sinusoidal signal, the sinusoidal signal generator first obtains a first target ratio between a target sampling frequency of the target sinusoidal signal and a preset sampling frequency of the preset sinusoidal signal, where the purpose of this operation step is to determine that it is most appropriate to select one sampling point every few sampling points in the process of uniformly sampling the sampling points of the preset sinusoidal signal; when the sinusoidal signal generator obtains a first target ratio between the target sampling frequency and the preset sampling frequency, the sinusoidal signal generator can uniformly extract first sampling points from the sampling points of the preset sinusoidal signal according to the first target ratio.

It can be understood that, after the sinusoidal signal generator uniformly extracts the first sampling points from the sampling points of the preset sinusoidal signal according to the first target ratio, the sinusoidal signal generator is equivalent to obtain the sinusoidal function of the target sinusoidal signal with the target sampling frequency at each sampling point in the 1/4 sampling period, in this case, the sinusoidal signal generator can obtain the target sinusoidal signal with the target sampling frequency by using the first sampling points according to the axial symmetry of the sinusoidal signal.

Specifically, the mathematical expression of the first sampling point is as follows:

sin(i'×N)%f0,i<f0

wherein i' is the serial number of the first sampling point, and the% represents the remainderN is a first target ratio, f0Is a preset sampling frequency.

In the present embodiment, a mathematical model expression of the first sampling point is provided to further increase the accuracy of the first sampling point in the selecting process. Here, by way of a specific example, it is assumed that a preset sinusoidal signal with a preset sampling frequency of 16000Hz is stored in the sinusoidal signal generator in advance, that is, assuming that the sampling period of a standard preset sinusoidal signal is 1s, when the sampling frequency of the preset sinusoidal signal is 16000Hz, the preset sinusoidal signal of one period is divided into 16000 points on average, and due to the axial symmetry of the sinusoidal signal, only the sinusoidal function values of the preset sinusoidal signal at the first 4000 sampling points need to be stored in the sinusoidal signal generator. Referring to fig. 2, fig. 2 is a schematic flow chart illustrating a process of obtaining a sine function value at each sampling point of a preset sine signal in a complete sampling period according to an embodiment of the present invention.

The mathematical expression of the sine function value at the ith sampling point in the preset sine signal is as follows:

table(i)=sin(2π·i/16000),0≤i≤4000;

wherein i is a serial number of a sampling point in a preset sinusoidal signal.

When the target sampling frequency of the target sinusoidal signal is an integral multiple of the preset sampling frequency, namely, 1Hz of the preset sampling frequency corresponds to NHz of the target sampling frequency, the sinusoidal signal generator only needs to continuously extract the sampling points with the interval of N from the preset sinusoidal signal to obtain a first sampling point, and then the target sinusoidal signal can be obtained according to the first sampling point. Referring to fig. 3, fig. 3 is a schematic flow chart of when the target sampling frequency of the target sinusoidal signal is less than the preset sampling frequency of the preset sinusoidal signal, the sampling points with the interval N are extracted from the preset sinusoidal signal.

Obviously, the technical scheme provided by the embodiment can make the acquisition process of the target sinusoidal signal simpler and easier.

Based on the above embodiments, this embodiment further describes and optimizes the technical solution, and as a preferred implementation, the above steps: utilize taylor's series to carry out even interpolation between two adjacent sampling points of predetermineeing sinusoidal signal to obtain the process of target sinusoidal signal, include:

acquiring a second target ratio between the target sampling frequency and the preset sampling frequency;

and on the basis of the Taylor series, uniformly inserting second sampling points with a second target ratio between two adjacent sampling points of the preset sinusoidal signal so as to acquire the target sinusoidal signal by using the sampling points and the second sampling points of the preset sinusoidal signal.

In this embodiment, a specific implementation method is provided for the sinusoidal signal generator to perform uniform interpolation on the preset sinusoidal signal according to the taylor series to obtain the target sinusoidal signal. In the method, a second target ratio between a target sampling frequency of a target sinusoidal signal and a preset sampling frequency of a preset sinusoidal signal is obtained. It can be understood that, when a second target ratio between the target sampling frequency and the preset sampling frequency is obtained, the sinusoidal signal generator can determine how many sampling points need to be inserted between two adjacent sampling points of the preset sinusoidal signal, and then the target sinusoidal signal with the target sampling frequency can be obtained.

When the sinusoidal signal generator obtains the second target ratio, the sinusoidal signal generator can uniformly insert second sampling points with the quantity being the second target ratio between two adjacent sampling points of the preset sinusoidal signal according to the Taylor series. It can be thought that, when the sinusoidal signal generator inserts a second target ratio of second sampling points between two adjacent sampling points of the preset sinusoidal signal, the sinusoidal signal generator obtains a sinusoidal function value of the target sinusoidal signal with the target sampling frequency at each sampling point in the 1/4 sampling period, and then, the sinusoidal signal generator can obtain the target sinusoidal signal of the whole sampling period according to the axial symmetry of the sinusoidal function.

Specifically, the mathematical expression of the second sampling point is as follows:

sin(i)+j×K1×cos(i)-j×j×K2×sin(i);

in the formula, K1=2π/[f0×(N+1)],i is the serial number of a sampling point in the preset sinusoidal signal, and j is the serial number of a second sampling point inserted between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signal.

In correspondence with the mathematical expression of the first sampling point disclosed in the above embodiment, in the present embodiment, the mathematical expression of the second sampling point is also provided correspondingly. Referring to fig. 4, fig. 4 is a schematic flow chart illustrating that N second sampling points are inserted between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signal when the target sampling frequency of the target sinusoidal signal is less than the preset sampling frequency of the preset sinusoidal signal. When the sampling period of the target sinusoidal signal is N +1 times of the sampling period of the preset sinusoidal signal, the sinusoidal signal generator can insert N second sampling points between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signal to acquire the target sinusoidal signal, wherein the inserted second sampling points are sampling points corresponding to Taylor series expansion of the ith sampling point in the preset sinusoidal signal.

Since the function f (x) is at point x0The Taylor series expansion expression is:

f(x)=f(x0)+f'(x0)(x-x0)+f2(x0)/2!(x-x0)+...;

wherein x is an independent variable.

Therefore, the Taylor series expansion corresponding to the sine function is:

sin(i)+j×K1×cos(i)-j×j×K2×sin(i)+...;

in the formula, K1=2π/[f0×(N+1)],i is the serial number of the sampling point in the preset sinusoidal signal, j is the second sampling point inserted between the ith sampling point and the (i + 1) th sampling point of the preset sinusoidal signalThe sequence number of the sample point.

It should be noted that, a large number of experimental verifications show that only the first three terms of taylor series of sinusoidal functions are expanded, the interpolation error of the target sinusoidal signal is maintained within 0 to 0.0000000019, and the requirements of practical application can be completely met, so in this embodiment, only the first three terms of taylor series of sinusoidal functions are expanded. Of course, in practical applications, if it is desired to achieve higher interpolation accuracy, more terms can be expanded on the taylor series of the sinusoidal function, and details are not described here.

Obviously, by the technical solution provided by the present embodiment, the consumption of computing resources for the sinusoidal signal generator can be relatively reduced.

Based on the foregoing embodiment, this embodiment further describes and optimizes the technical solution, and as a preferred implementation, the method for generating a sinusoidal signal further includes:

and storing the mapping relation between the sine function value of the preset sine signal at each sampling point and the corresponding sampling point in the sine signal generator in a table form in advance.

In practical applications, in order to further increase the speed of the sinusoidal signal generator in generating the target sinusoidal signal, a mapping relationship between a sinusoidal function value of a preset sinusoidal signal at each sampling point and a corresponding sampling point may be stored in the sinusoidal signal generator in a table form in advance.

It can be understood that, because the sine signal generator can more quickly retrieve the sine function value of the preset sine signal at each sampling point from the memory of the sine signal generator, the speed of the sine signal generator in generating the target sine signal can be further increased.

Referring to fig. 5, fig. 5 is a structural diagram of a sinusoidal signal generating device according to an embodiment of the present invention, the generating device includes:

the signal calling module 21 is configured to, when a trigger instruction for acquiring a target sinusoidal signal by the servo driver is received, call a pre-stored preset sinusoidal signal from the sinusoidal signal generator; the preset sinusoidal signal only records a sinusoidal function value corresponding to each sampling point of the preset sinusoidal signal in the 1/4 sampling period;

the signal judgment module 22 is configured to judge whether a target sampling frequency of the target sinusoidal signal is greater than or equal to a preset sampling frequency of a preset sinusoidal signal;

the first sending module 23 is configured to, if the target sampling frequency is greater than or equal to the preset sampling frequency, uniformly sample sampling points of a preset sinusoidal signal to obtain a target sinusoidal signal, and send the target sinusoidal signal to the servo driver;

and the second sending module 24 is configured to, if the target sampling frequency is less than the preset sampling frequency, perform uniform interpolation between two adjacent sampling points of the preset sinusoidal signal by using a taylor series to obtain a target sinusoidal signal, and send the target sinusoidal signal to the servo driver.

Preferably, the method further comprises the following steps:

and the relation storage module is used for storing the mapping relation between the sine function value of the preset sine signal at each sampling point and the corresponding sampling point in the sine signal generator in a table form.

The device for generating a sinusoidal signal provided by the embodiment of the invention has the beneficial effects of the method for generating a sinusoidal signal disclosed in the foregoing.

Referring to fig. 6, fig. 6 is a structural diagram of a sinusoidal signal generating device according to an embodiment of the present invention, where the generating device includes:

a memory 31 for storing a computer program;

a processor 32 for implementing the steps of a method of generating a sinusoidal signal as disclosed in the foregoing when executing the computer program.

The sinusoidal signal generation device provided by the embodiment of the invention has the beneficial effects of the sinusoidal signal generation method disclosed in the foregoing.

Accordingly, the embodiment of the present invention also discloses a computer readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for generating a sinusoidal signal as disclosed in the foregoing are implemented.

The computer-readable storage medium provided by the embodiment of the invention has the beneficial effects of the method for generating the sinusoidal signal disclosed in the foregoing.

The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.

Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

The method, the apparatus, the device and the medium for generating a sinusoidal signal provided by the present invention are described in detail above, and a specific example is applied in the present document to illustrate the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种太赫兹基波混频模块

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!