1
$\begingroup$

I move a device by sending a sine wave proportional to the displacement. I would like to modify the amplitude and mean value dynamically.

For example at the beginning I would like to go from :

Signal(t) = 1 * sin(t) + 1

to:

Signal(t) = 0.95 *sin(t) + 0.95

My issue is that I don't know how to do that without having a big step in my signal, which is unacceptable for my application. For now, all I have is something that change the coefficient on a "long" time, by small step (1>0.99>0.98>0.97>0.96>0.95) so that the "steps" in the output signal remain small, but it is not very clean.

$\endgroup$
  • 1
    $\begingroup$ What you're doing is an amplitude modulator. Have you tried low-pass filtering the "big step" in the input signal? That might take care of the problem. $\endgroup$ – MBaz Sep 14 '15 at 12:35
2
$\begingroup$

There's no problem letting the coefficients be a slowly varying function of time,

$$S(t)=a(t)\sin(t)+b(t),$$

for example a linear ramp $$a(t)=(a_1-a_0)\frac{t-t_0}{t_1-t_0}+a_0$$ for $t\in[t_0,t_1]$ and similar for $b(t)$.

enter image description here

$\endgroup$
1
$\begingroup$

The output is $c(t)\times\left(\sin\left(t\right) + 1\right)$, where $c(t)$ is the coefficient as function of time. That's multiplication by $c(t)$ in time domain, meaning that it will be convolution in frequency domain. Convolution effectively spreads the spectrum of $\left(\sin\left(t\right) + 1\right)$ which originally consists of three peaks (negative frequency of the sinusoid, 0 Hz, and positive frequency of the sinusoid). If this spread is a problem to you, you can control it by lowpass filtering $c(t)$ before doing the multiplication. Say you lowpass filter $c(t)$ at 10 Hz. The result is that the spectrum will not be spread to more than ±10 Hz away from the original peaks.

In your application you may not want a brick-wall filter like that, because its step response has an overshoot; its output goes past the original value range of $c(t)$. The easiest thing to do may be to use a number of identical one-pole lowpass filter stages in series. A one-pole lowpass filter has no overshoot. Neither has a cascade of overshoot-free filter stages. A single stage is simply $\text{out}(t) = a\ \text{in}(t) + (1-a)\ \text{out}(t)$, where $a$ is a coefficient between 0 and 1. Each stage increases the slope of the filter's frequency response by 6 dB/octave.

Using an infinite impulse response (IIR) filter such as the above means that the output only asymptotically approaches the correct value. If you want the correct value to be reached within a predetermined time, then you might want to look into finite impulse response (FIR) filters. For that, one of the usual window functions could be used as the impulse response of the FIR filter. The length of the impulse response equals the reaching time.

$\endgroup$
0
$\begingroup$

One solution is to chose the changeover time as when

$$ \sin(t) + 1 = 0.95 \sin(t) + 0.95 = 0 $$

i.e. when $t \approx -\frac{\pi}{2} + 2\pi k$.

Another solution is to change the phase of the second sinusoid so that

$$ \sin(t) + 1 = 0.95\sin(t + \phi) + 0.95 $$

though you will want to make sure that the derivative of both signals is the same, rather than just their magnitude.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.