Just a quick thought, one difference could be that in the Simulink case, your
8kHz sample rate is probably an _exact_ multiple of the 60Hz waveform, but in
the real-world case, it may not be. Try modifying your Simulink example to use
a slightly different frequency such as 60.37 Hz or something and see what
happens.
You could also try simplifying the problem by downsampling just the 60Hz
waveform without the modulation.
"Jaime Andrés Aranguren Cardona" <
[email protected]> wrote in message
news:1103046565.72fb8397a7036cd0ab33545d0fe7c860@t eranews...
> Hello,
>
> For a project which I'm working on, I have a 60Hz sinewave modulated with a
> square wave at 0.5Hz, modulation is 2.72%
>
> The signal comes sampled at 8kHz, I should downsample it to 200Hz, so M =
> 40. I do that in two stages, first with M1 = 10, then with M2 = 4. I
> implemented polyphase structure in Simulink, and runs great. By "great" I
> mean that the output signal, sampled at 200Hz, preserves the squarewave
> shape perfectly.
>
> Ths structure used in Simulink is the one in P.P. Vaidyanathan's book
> "Multirate Systems and Filter Banks", figure 4.3-4 (a), page 124.
>
> However, In my C implementation (on SHARC, BTW), the downsampled signal
> looks weird. By "weird" I mean that the envelope of the output signal,
> instead of being flat (square) as it is expected to be, seems more like a
> low frequency sinusoid, still it is noticeable when the amplitude rises and
> falls at the same frequency of the original modulating square wave.
>
> Given this information, and the fact that Simulink implementation maps
> directly to the figure in Vaidyanathan's book, I am pretty sure that I have
> some mistakes in my C implementation, but I can't find them.
>
> Could someone here please give me advice on what mistakes in implementing
> the polyphase M-fold decimation filters lead to the sort of "weirdness" that
> I got from my C implementation? That would be of much support in finding
> what I did wrong.