The present disclosure relates to communication technology, in particular to a method for generating a control signal, an electronic device and a storage medium.
The vibration feedback with respect to existing electronic devices such as mobile phones, tablet computers, and the like, is an intuitive physical experience which the experiencer feels and which is brought by the work of the touch controller, and diverse experience feedbacks require to be stimulated by different input signals. Many times the input signal is obtained based on the direct output of the touch controller. In order to achieve a certain vibration effect, designers start from the input terminal of the touch controller and inversely derive the input control signal of the touch controller many times. However, in the process of inverse derivation, there is a certain probability that the obtained input control signal will have a nonzero initial point or end point, which means that the control signal does not start from 0. The non-zero start of the excitation signal is equivalent to introducing a step signal into the signal. The current linear excitation motor (LRA) will produce an oscillating response to the step signal, affecting user experience.
Therefore, it is necessary to provide a method for generating a control signal that makes the control signal starts from 0.
An objective of the present disclosure is to provide a method for generating a control signal, an electronic device, and a storage medium, so that the control signal starts from 0, and the oscillation response is reduced.
The technical solution of the present disclosure is as follows:
a method for generating a control signal, which includes:
acquiring a relationship curve between an initial signal and time, where the relationship curve includes several sampling points and a value of the initial signal and the time corresponding to each sampling point;
determining whether the value of the initial signal corresponding to the first sampling point of the relationship curve is 0;
constructing an optimization function according to the relationship curve if the value of the initial signal corresponding to the first sampling point of the relationship curve is not 0;
multiplying the value of the initial signal corresponding to each sampling point by a corresponding value of the optimization function to obtain an optimized value of each sampling point;
generating a control signal according to a corresponding relationship between the optimized value and the time, where the control signal is used to drive the motor to vibrate.
Further, the optimization function is: y=1−e−λt, where λ is a fixed value and t is the time.
Further,
where n is the number of the sampling points.
Further, before multiplying the value of the initial signal corresponding to each sampling point by the corresponding value of the optimization function, the method further includes:
normalizing the relationship curve between the initial signal and the time.
Further, the method further includes:
determining whether the value of the initial signal corresponding to the last sampling point of the relationship curve is 0;
arranging the sampling points on the relationship curve in a reverse order if the value of the initial signal corresponding to the last sampling point of the relationship curve is not 0, and multiplying the value of the initial signal corresponding to each sampling point arranged in the reverse order by the corresponding value of the optimization function to obtain the optimized value of each sampling point arranged in the reverse order.
Further, the initial signal is a voltage signal.
The present disclosure further provides an electronic device, including a processor and a memory storing computer readable programs that are configured to be executed by the processor, and that, as a result of being executed by the processor, perform the above-mentioned method.
The present disclosure further provides a computer-readable storage medium storing computer programs that, when being executed by the processor, perform the above method.
The beneficial effects of the present disclosure are as follows: the relationship curve where the value of the initial signal corresponding to the first sampling point is not 0 is optimized to obtain the optimized value of each sampling point by constructing an optimization function, the control signal is generated according to the corresponding relationship between the optimized value and the time, and the control signal with respect to the initial signal with the value of 0 corresponding to the first sampling point is obtained, so as to drive the motor to vibrate, thereby reducing the oscillation response and improving the user experience.
The present disclosure will be further described below with reference to accompanying drawings and embodiments.
As shown in
As shown in
As shown in
In step S101, a relationship curve between the initial signal and the time is acquired, and the relationship curve includes several sampling points and a value of the initial signal and the time corresponding to each sampling point.
The relationship curve between the initial signal and the time is calculated from the motion parameters of the motor. For example, the relationship curve between the initial signal and the time is calculated according to the relationship between a displacement and the time or an acceleration and the time during the vibration of the motor.
In step S102, whether the value of the initial signal corresponding to the first sampling point of the relationship curve is 0 is determined.
The first sampling point is a starting point of the initial signal, that is, the sampling point corresponding to the time of 0. As shown in
In step S103, an optimization function is constructed according to the relationship curve if the value of the initial signal corresponding to the first sampling point of the relationship curve is not 0.
The optimization function needs to be a concave function that gradually gets closer to 1 at the beginning, and then becomes a straight line that is infinitely close to 1, that is, the optimized signal initially slowly rises from 0, and then an amplitude of the optimized signal is infinitely close to the original signal.
In one embodiment, the optimization function is: y=1−e−λt, where λ is a fixed value and t is the time. Preferably,
where n is the number of the sampling points. It should be noted that λ may also be set according to the experience value.
In step S104, the value of the initial signal corresponding to each sampling point is multiplied by the corresponding value of the optimization function to obtain the optimized value of each sampling point.
Specifically, the value of the optimization function is calculated according to the time of each sampling point, and multiplied by the value of the initial signal corresponding to the sampling point to obtain the optimized value of the sampling point.
In one embodiment, the relationship curve between the initial signal and the time is first normalized, then a maximum value of the initial signal after being normalized is recorded and multiplied by the optimization function to restore its true value.
In step S105, the control signal is generated according to a corresponding relationship between the optimized value and the time, and the control signal is used to drive the motor to vibrate.
Specifically, each optimized value corresponds to one time, and a functional relationship may be obtained according to the corresponding relationship between the optimized value and the time, and a relationship curve between the optimized value and the time, that is, the control signal, is drawn. As shown in
In another embodiment, the method for generating a control signal further includes: determining whether the value of the initial signal corresponding to the last sampling point of the relationship curve is 0; arranging the sampling points on the relationship curve in a reverse order if the value of the initial signal corresponding to the last sampling point of the relationship curve is not 0; and multiplying the value of the initial signal corresponding to each sampling point arranged in the reverse order by the corresponding value of the optimization function to obtain the optimized value of each sampling point arranged in the reverse order.
Specifically, the last sampling point of the relationship curve is an end point of the initial signal. If the end point of the initial signal needs to be optimized to 0, the relationship curve between the initial signal and the time is arranged in the reverse order. For example, the value of the initial signal corresponding to each sampling point are arranged in the reverse order to form a functional relationship with respect to the time after being arranged in the reverse order. According to the time corresponding to each sampling point arranged in the reverse order, the value of the optimization function is calculated, and multiplied by the value of the initial signal corresponding to the sampling point to obtain the optimized value of the sampling point, that is, the optimized value of each sampling point arranged in the reverse order. The optimized value of each sampling point arranged in the reverse order is arranged in the reverse order again, forming a relationship curve with respect to time. That is, the control signal is obtained, so that the control signal with the end point of 0 is obtained, thereby reducing the oscillation response and improving the user experience.
The electronic device in the embodiments of the present disclosure and the method in the above embodiment are two aspects based on the same inventive concept. An implementation process of the method has been described in details above, so those skilled in the art may clearly understand the implementation process of the electronic device in this embodiment according to the above description. For the sake of conciseness of the description, it will not be repeated herein.
It can be known from the description of the above embodiments that those skilled in the art may clearly understand that the present disclosure may be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution of the present disclosure, or part of the present disclosure that makes contributions to existing technologies, may be embodied in the form of software products in essence. The present disclosure also relates to a computer-readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, and the like, on which computer programs are stored, and the computer programs, when executed by a processor, perform the above method.
The method for generating a control signal, the electronic device and the storage medium in the present disclosure optimize the relationship curve where the value of the initial signal corresponding to the first sampling point is not 0 by constructing an optimization function to obtain the optimized value of each sampling point. The control signal is generated according to the corresponding relationship between the optimized value and the time, and the control signal with the initial signal of 0 corresponding to the first sampling point is obtained to drive the motor to vibrate, thereby reducing the oscillation response and improving the user experience.
The above are only embodiments of the present disclosure. It should be indicated that those of ordinary skill in the art can make improvements without departing from the inventive concept of the present disclosure, and such improvements belong to the protection scope of the present disclosure.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2019/093078 | Jun 2019 | US |
Child | 16994661 | US |