Switching sinusoidal signals at the same ampltude and in the same half wave

Hi!
I have the following problem in MATLAB/Simulink and I hope to get some support and/or ideas:
I need to switch at runtime between a sinusoidal signal and a distorted sinusoidal signal. The signals might have a phase shift as well as a slightly different frequency.
The external trigger signal accesses directly the real-time data forcing the signal sources in the simulink model to switch.
However, in order to be allowed to switch, the signals must have the same amplitude and both of them must be either in the positive or negative half wave.
Checking for the same amplitude is quite simple but how can I check the phasing? And if I know the phasing, how can I shift one of the signals so that they are in the same half wave and still have the same amplitude?
I appreciate any response
Kind regards

Answers (1)

Doing exactly what you describe can be pretty complex. If you are constructing the signals in the model using basic blocks, it might be possible to play with the equations to determine when your conditions will happen. Or you can enable (in other words "start") the second signal in specific condition, that way you don't need to check both signals match, you check only the active one. This really depends on how you create these signals.
If the reason you are doing that is to obtain a smooth transition between the 2 signals, I would take another approach. Instead of trying to implement an instantaneous switch at the prefect time, why not doing a progressive switching?
You can multiply the first signal by a signal going smoothly from 1 to 0 and the second one going from 0 to 1 (can be a ramp, or even better a polynomial). I am not sure if this is appropriate for your application, but I used that often.

2 Comments

Dear Guy
Thank you a lot for your response.
I also thought about the possibility of starting the other signal if a specific condition is true. This seems to be the best solution.
Let´s say the external trigger signal for the switching operation comes between the start and end point of the distorted sinusoidal signals period.
I would then have to wait for the zero crossing indicating that the period of the distorted signal is finished. Afterwards, I would immediately switch to the second sinusoidal signal making sure that the start point of that signal is equal to the end point of the distorted signal (in this case zero).
In this way, I could get a smooth switching operation between the two signals.
However, the key question is how to find the zero crossing indicating the end of the distorted signal. One main problem is that there might be some jitter around zero making it hard to find the right zero crossing (see Figure 1: https://ccrma.stanford.edu/~pdelac/154/m154paper.htm)
Some ideas how to find the "right" zero crossing?
Kind regards
I am sorry, but this is outside my knowledge of signal processing.
The link you provide seems to be in the right direction.
I already saw active noise control algorithms being able to identify phase and amplitude of one component of a noisy signal, the using this info to artificially generate a reference for a notch filter. You might want to give a try searching in this direction.

Sign in to comment.

Asked:

on 20 Jun 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!