0
$\begingroup$

Suppose we have this signal from this wiki page

$a(t)=\sin(\varphi_o + f_0t + (f_1-f_0)t^2/T)$

The article tells that T is a period of chirp modulation in which frequency changes. So my question is how to create signal with constant $f_1$ frequency after T? This is a wave from article

$\endgroup$
0
$\begingroup$

how to create signal with constant $f_1$ frequency after T?

Find the instantaneous phase at the end of the $T$ interval and keep adding it to the phase that makes the $\sin()$ "go round".

A plain simple oscillator at some frequency $f$ has its phase increasing at a constant rate.

Here is an example (in GNU Octave but easily transferable to other platforms as well):

Fs = 44100; % Sampling frequency in Hz
T = 1; % Total duration of the signal in seconds
f = 120; % Frequency of the oscillator
t = 0:(1./Fs):(T - (1./Fs)); % Time vector
p = 2.0 .* pi .* t; %Phase vector
y = sin(f.*p);

Now y contains our 120 Hz sinusoid sampled at 44.1kHz.

Notice here that phase (p) is a "straight line" that grows at a constant rate of $\frac{2 \pi f}{Fs}$.

When the oscillator is "chirping", the rate of change of the phase is variable. For example:

Fs = 44100; % Sampling frequency in Hz
T = 1; % Total duration of the signal in seconds
f0 = 1; % Start chirp at
f1 = 120; % end chirp at (Better keep f1>f0)
t = 0:(1./Fs):(T - (1./Fs)); % Time vector
p = 2.0 .* pi .* t; %Phase vector
y = sin(f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2));

Now, this looks like:

enter image description here

And the rate of change of the phase of the $\sin$ is:

enter image description here

Now, from the first example, the phase "step" is f.*p(2)-f.*p(1) == 0.017097 and from the second example, after doing:

s = diff(f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2)); % Get the first derivative of phase to find the **rate of change**.

The "last" rate of change is s(end) == 0.017097.

So, to have the oscillator stay at the chirp's concluding frequency, keep accumulating the phase at the constant rate you are after from the last known value of the chirp's phase (to avoid phase jumps). For example:

r = f0.*p + 2.*pi.*(((f1-f0)/(2.*T)).*t.^2);  % The phase as above.   
z = r(end) + cumsum(ones(1,T.*Fs).*0.017097); % A running sum of duration T.*Fs (samples).

Now, if you feed the combined result of r, z into the oscillator y with something like y = sin([r,z]); it would look like:

enter image description here

...with a rate of change of:

enter image description here

Hope this helps.

$\endgroup$
  • $\begingroup$ Thank you! I thought about that I need to fix the phase of the signal. $\endgroup$ – lisichka ggg Apr 24 at 16:40
  • $\begingroup$ @lisichkaggg No worries, all the best with your project. $\endgroup$ – A_A Apr 24 at 20:31
0
$\begingroup$

If you want the frequency to linearly increase from $f_0$ to $f_1$ (i.e., a chirp) then the solution is given in the answer to this related question.

If you want a sinusoid with a constant frequency $f_0$ for $t<T$, and with frequency $f_1$ for $t>T$, then - since the phase is ($2\pi$ times) the integral of the frequency - the corresponding phase is given by

$$\frac{\phi(t)}{2\pi}=\begin{cases}f_0t,&t<T\\f_1(t-T)+f_0T,&t>T\end{cases}$$

where I've chosen the constants in such a way that the phase is continuous at $t=T$.

The desired signal is given by

$$x(t)=\sin(\phi(t))\tag{1}$$

$\endgroup$
  • $\begingroup$ The seconds answer is what I need. Thanks for answer! $\endgroup$ – lisichka ggg Apr 24 at 14:53

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.