Forums

Where do the errors come from in a simple Simulink model?

Started by Peter Mairhofer October 14, 2014
Hi all,

Thanks for all who replied to "Typical error level in RF systems". Based
on that thread I started from scratch a *simple* I/Q transceiver in
Simulink and I am not able to get more than about -41 dB NMSE. Ridiculous.

If I add the proposed equalizer (numer of taps doesn't matter) I can get
up to -47 dB. Not great either.

The model is very easy: http://snag.gy/6aXXm.jpg

A 20 MHz BW signal (baseband I/Q) sampled at fs=100 MHz is upconverted
to fc=600 MHz with ideal multiplicative mixing, then downconverted again
and ADC'ed at fs using the "To Workspace" block.

The DAC reconstruction filter is a simple 7th order Butterworth with
fcut = fs/4 = 25 MHz. At the right edge of the first image, this
corresponds to an attenuation of -78 dB. The actual attenuation is even
lower due to sinc droop of the first-order-hold.

The receive filter (image rejection) is a simple 5th order Butterworth
with fcut = fs = 100 MHz. At the image at 1.19 GHz, the attenuation is
-108 dB.

The recived signal is time-aligned using fitSignal_120825 from Markus
Nentwig.

Increasing the maxstep size decreases the noise floor but does not
change NMSE, so I assume it is caused by inband errors.

This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect"
although the noise floor is not perfect but can probably decreases by
decreasing maxstep further (in this plot, maxstep=Ts/100).

A zoom http://snag.gy/ikAQq.jpg reveals that there is indeed inband
distortion.

Both filters have a pretty linear phase in the signal band (20 MHz) so I
wonder if the error can come from the non-linear phase. This
construction is as ideal (and unpractical regarding filter orders) as it
gets. Furthermore, I when I add the equalizer I can boost it to -45.46
dB - actually nothing.

Where do the errors come from? This model is the most ideal I could
imagine so I would expect <-100 dB out of the box (limited by image
rejection) and with certain correction even much more (-160dB).


Thanks for helping me out
Peter



PS: I know this is not a "debug my code" community. I have, however,
created a minimal piece of code to reproduce the results, should it help ...

On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net>
wrote:

>Hi all, > >Thanks for all who replied to "Typical error level in RF systems". Based >on that thread I started from scratch a *simple* I/Q transceiver in >Simulink and I am not able to get more than about -41 dB NMSE. Ridiculous. > >If I add the proposed equalizer (numer of taps doesn't matter) I can get >up to -47 dB. Not great either. > >The model is very easy: http://snag.gy/6aXXm.jpg > >A 20 MHz BW signal (baseband I/Q) sampled at fs=100 MHz is upconverted >to fc=600 MHz with ideal multiplicative mixing, then downconverted again >and ADC'ed at fs using the "To Workspace" block. > >The DAC reconstruction filter is a simple 7th order Butterworth with >fcut = fs/4 = 25 MHz. At the right edge of the first image, this >corresponds to an attenuation of -78 dB. The actual attenuation is even >lower due to sinc droop of the first-order-hold. > >The receive filter (image rejection) is a simple 5th order Butterworth >with fcut = fs = 100 MHz. At the image at 1.19 GHz, the attenuation is >-108 dB.
The pic of the model you linked doesn't include a DAC, reconstruction filter, image rejection filter, equalizer, or other stuff that you mention. Maybe post a diagram of what you're really doing instead?
>The recived signal is time-aligned using fitSignal_120825 from Markus >Nentwig. > >Increasing the maxstep size decreases the noise floor but does not >change NMSE, so I assume it is caused by inband errors.
Max step size in what? The equalizer training?
>This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >although the noise floor is not perfect but can probably decreases by >decreasing maxstep further (in this plot, maxstep=Ts/100).
I'm guessing by the shape of the spectrum that this is a multicarrier system? If it is, then I'm not sure what the pulse shaping filter is doing in the diagram you linked. It shouldn't be there in a multicarrier system (unless it's doing tapering or CP insertion? There's no way to tell). If it's not a multicarrier system, then your spectrum doesn't look very good. You haven't said what sort of modulation you're using (that I've noticed, anyway), so it's hard to really say anything for certain.
>A zoom http://snag.gy/ikAQq.jpg reveals that there is indeed inband >distortion.
If the data is random, that's not distortion it's the randomness of the data.
>Both filters have a pretty linear phase in the signal band (20 MHz) so I >wonder if the error can come from the non-linear phase.
Which filters?
> This >construction is as ideal (and unpractical regarding filter orders) as it >gets. Furthermore, I when I add the equalizer I can boost it to -45.46 >dB - actually nothing.
Previously above you said the EQ provided a 6dB improvement. What do you really mean? If the EQ really does improve it 6dB as you said earlier, then there is linear distortion from somewhere. It could be filter mismatches, it could be a lot of things, but I'm confused as to what you're actually doing and the diagram you linked doesn't match your description, so it's a bit tough to say.
> >Where do the errors come from?
Often from the programmer.
>This model is the most ideal I could >imagine so I would expect <-100 dB out of the box (limited by image >rejection) and with certain correction even much more (-160dB). > > >Thanks for helping me out >Peter > > > >PS: I know this is not a "debug my code" community. I have, however, >created a minimal piece of code to reproduce the results, should it help ... >
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net>
wrote:

>Hi all, > >Thanks for all who replied to "Typical error level in RF systems". Based >on that thread I started from scratch a *simple* I/Q transceiver in >Simulink and I am not able to get more than about -41 dB NMSE. Ridiculous. > >If I add the proposed equalizer (numer of taps doesn't matter) I can get >up to -47 dB. Not great either. > >The model is very easy: http://snag.gy/6aXXm.jpg > >A 20 MHz BW signal (baseband I/Q) sampled at fs=100 MHz is upconverted >to fc=600 MHz with ideal multiplicative mixing, then downconverted again >and ADC'ed at fs using the "To Workspace" block. > >The DAC reconstruction filter is a simple 7th order Butterworth with >fcut = fs/4 = 25 MHz. At the right edge of the first image, this >corresponds to an attenuation of -78 dB. The actual attenuation is even >lower due to sinc droop of the first-order-hold. > >The receive filter (image rejection) is a simple 5th order Butterworth >with fcut = fs = 100 MHz. At the image at 1.19 GHz, the attenuation is >-108 dB. > >The recived signal is time-aligned using fitSignal_120825 from Markus >Nentwig. > >Increasing the maxstep size decreases the noise floor but does not >change NMSE, so I assume it is caused by inband errors. > >This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >although the noise floor is not perfect but can probably decreases by >decreasing maxstep further (in this plot, maxstep=Ts/100).
Quick follow-up: That's not a "noise floor", that's a little bit of spectral regrowth from the subcarriers (I'm still assuming this is multicarrier from the spectrum shape), and it appears to me that the regrowth is >75dB down. Not sure how you're measuring SNR, but just looking at the spectrum is should be a LOT better than 40.72dB. The spurs on the edges of the plot do not appear to be part of the signl and I can't tell how high they go. If you're including them in the noise power calculation it'll probably affect things negatively.
>A zoom http://snag.gy/ikAQq.jpg reveals that there is indeed inband >distortion. > >Both filters have a pretty linear phase in the signal band (20 MHz) so I >wonder if the error can come from the non-linear phase. This >construction is as ideal (and unpractical regarding filter orders) as it >gets. Furthermore, I when I add the equalizer I can boost it to -45.46 >dB - actually nothing. > >Where do the errors come from? This model is the most ideal I could >imagine so I would expect <-100 dB out of the box (limited by image >rejection) and with certain correction even much more (-160dB). > > >Thanks for helping me out >Peter > > > >PS: I know this is not a "debug my code" community. I have, however, >created a minimal piece of code to reproduce the results, should it help ... >
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
Hi Eric,

On 2014-10-14 15:40, Eric Jacobsen wrote:
> On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net> > wrote: > >> Hi all, >> >> Thanks for all who replied to "Typical error level in RF systems". Based >> on that thread I started from scratch a *simple* I/Q transceiver in >> Simulink and I am not able to get more than about -41 dB NMSE. Ridiculous. >> >> If I add the proposed equalizer (numer of taps doesn't matter) I can get >> up to -47 dB. Not great either. >> >> The model is very easy: http://snag.gy/6aXXm.jpg >> >> A 20 MHz BW signal (baseband I/Q) sampled at fs=100 MHz is upconverted >> to fc=600 MHz with ideal multiplicative mixing, then downconverted again >> and ADC'ed at fs using the "To Workspace" block. >> >> The DAC reconstruction filter is a simple 7th order Butterworth with >> fcut = fs/4 = 25 MHz. At the right edge of the first image, this >> corresponds to an attenuation of -78 dB. The actual attenuation is even >> lower due to sinc droop of the first-order-hold. >> >> The receive filter (image rejection) is a simple 5th order Butterworth >> with fcut = fs = 100 MHz. At the image at 1.19 GHz, the attenuation is >> -108 dB. > > The pic of the model you linked doesn't include a DAC, reconstruction > filter, image rejection filter, equalizer, or other stuff that you > mention. Maybe post a diagram of what you're really doing instead?
Oh, they should. As mentioned in the subject this is a Simulink model maybe I should have emphasized that again. I am not yet sure if I do something conceptionally wrong or if it is related to Simulink. First of all, forget about the equalizer. It is the underlying MATLAB code. As I mentioned I think an equalizer should be even required under these conditions. But I can annotate the model even more: http://snag.gy/pNMBC.jpg To be clear: The figure is a black box. Its input is complex valued x[n], its output complex valued ytilde[n] (both sampled at 100 MHz) ...
>> The recived signal is time-aligned using fitSignal_120825 from Markus >> Nentwig.
... this gives then y[n].
>> Increasing the maxstep size decreases the noise floor but does not >> change NMSE, so I assume it is caused by inband errors. > > Max step size in what? The equalizer training?
No maxstep setting of the continuous-time solver (i.e., the Simulink simulation setting). I just use "ode45", by the way.
>> This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >> although the noise floor is not perfect but can probably decreases by >> decreasing maxstep further (in this plot, maxstep=Ts/100). > > I'm guessing by the shape of the spectrum that this is a multicarrier > system?
No. It's just something like x = randn(N,1) + 1i*randn(N,1); X = fft(x); X([N*bw+1:N-N*bw-1) = 0; % just ideally bandlimit x to 20 MHz % (bw is sth. like bw=100MHz/20MHz) x = ifft(X);
> If it is, then I'm not sure what the pulse shaping filter is > doing in the diagram you linked.
The DAC outputs rect pulses (zero order hold). To get rid of the associated images around n*fs you need to shape the pulses, most prominently just with a lowpass filter. The more common name is probably reconstruction filter.
> It shouldn't be there in a > multicarrier system (unless it's doing tapering or CP insertion? > There's no way to tell). If it's not a multicarrier system, then > your spectrum doesn't look very good. You haven't said what sort of > modulation you're using (that I've noticed, anyway), so it's hard to > really say anything for certain.
At this point it's really a simple signal processing system, no communications or RF. No modulation, no CP etc. It's just a random signal, zero-order-held, passed through a filter, multiplied with a high-frequency sine ("upconversion"), multiplied again ("down conversion"), passed again through a filter (image rejection) and through an ideal ADC. It's really just the canonical I/Q transceiver, something like http://upload.wikimedia.org/wikipedia/commons/thumb/1/14/QAM_transmitter.svg/380px-QAM_transmitter.svg.png and http://upload.wikimedia.org/wikipedia/commons/thumb/5/58/QAM_receiver.svg/500px-QAM_receiver.svg.png
>> A zoom http://snag.gy/ikAQq.jpg reveals that there is indeed inband >> distortion. > > If the data is random, that's not distortion it's the randomness of > the data.
I do not have any noise sources. Of course the data is generated from a random source but once it is, it is the deterministic input signal.
>> Both filters have a pretty linear phase in the signal band (20 MHz) so I >> wonder if the error can come from the non-linear phase. > > Which filters?
The transmitters filter and the receive filter).
>> This >> construction is as ideal (and unpractical regarding filter orders) as it >> gets. Furthermore, I when I add the equalizer I can boost it to -45.46 >> dB - actually nothing. > > Previously above you said the EQ provided a 6dB improvement. What do > you really mean?
As mentioned above: 1.) I generate x[n] in MATLAB, send it through the Simulink system 2.) I get ytitlde and time-align it to get y[n] 3.) NMSE = 20*log10(norm(x-y)/norm(x)) = -41 dB 4.) If I further equalize y[n] using a FIR filter (as proposed by Markus in another post) I only get -56.46 dB using the same 20*log10(norm(x-y)/norm(x)) The equalizer is just built using a least squares fit on delayed output samples (post equalizer). But once again, this is not the most important point.
> If the EQ really does improve it 6dB as you said earlier, then there > is linear distortion from somewhere.
The filter responses probably.
> It could be filter mismatches, > it could be a lot of things, but I'm confused as to what you're > actually doing and the diagram you linked doesn't match your > description, so it's a bit tough to say.
I hope I clarified. Thanks Peter
On 2014-10-14 15:45, Eric Jacobsen wrote:
> On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net> > [...] >> This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >> although the noise floor is not perfect but can probably decreases by >> decreasing maxstep further (in this plot, maxstep=Ts/100). > > Quick follow-up: That's not a "noise floor", that's a little bit of > spectral regrowth from the subcarriers (I'm still assuming this is > multicarrier from the spectrum shape), and it appears to me that the > regrowth is >75dB down.
I hope I clarified this in my previous reply. So subcarriers and no spectral regrowth because everything is linear.
> Not sure how you're measuring SNR,
20*log10(norm(x-y)/norm(x)) which is nothing but the definition of NMSE: 10*log10(mean(abs(x-y)^2)/mean(abs(x)^2))
> but just > looking at the spectrum is should be a LOT better than 40.72dB.
And with this I agree (I'd expect -100dB or so), that's the reason for my question.
> The spurs on the edges of the plot do not appear to be part of the > signl and I can't tell how high they go. If you're including them in > the noise power calculation it'll probably affect things negatively.
I also wondered already where they can come from. I see no reason for them. As mentioned previously, if I set the maximum step size for the simulator very very low (Ts/10000) I expect that the green gets down more and more. I think this is the "noise" due to imperfect integration in the simulator. Peter
On Tue, 14 Oct 2014 16:29:16 -0700, Peter Mairhofer <63832452@gmx.net>
wrote:

>Hi Eric, > >On 2014-10-14 15:40, Eric Jacobsen wrote: >> On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net> >> wrote: >> >>> Hi all, >>> >>> Thanks for all who replied to "Typical error level in RF systems". Based >>> on that thread I started from scratch a *simple* I/Q transceiver in >>> Simulink and I am not able to get more than about -41 dB NMSE. Ridiculous. >>> >>> If I add the proposed equalizer (numer of taps doesn't matter) I can get >>> up to -47 dB. Not great either. >>> >>> The model is very easy: http://snag.gy/6aXXm.jpg >>> >>> A 20 MHz BW signal (baseband I/Q) sampled at fs=100 MHz is upconverted >>> to fc=600 MHz with ideal multiplicative mixing, then downconverted again >>> and ADC'ed at fs using the "To Workspace" block. >>> >>> The DAC reconstruction filter is a simple 7th order Butterworth with >>> fcut = fs/4 = 25 MHz. At the right edge of the first image, this >>> corresponds to an attenuation of -78 dB. The actual attenuation is even >>> lower due to sinc droop of the first-order-hold. >>> >>> The receive filter (image rejection) is a simple 5th order Butterworth >>> with fcut = fs = 100 MHz. At the image at 1.19 GHz, the attenuation is >>> -108 dB. >> >> The pic of the model you linked doesn't include a DAC, reconstruction >> filter, image rejection filter, equalizer, or other stuff that you >> mention. Maybe post a diagram of what you're really doing instead? > >Oh, they should. As mentioned in the subject this is a Simulink model >maybe I should have emphasized that again.
Many of us don't have or use simulink, so don't assume people know what's in simulink blocks.
>I am not yet sure if I do something conceptionally wrong or if it is >related to Simulink. > >First of all, forget about the equalizer. It is the underlying MATLAB >code. As I mentioned I think an equalizer should be even required under >these conditions. > >But I can annotate the model even more: > >http://snag.gy/pNMBC.jpg > >To be clear: The figure is a black box. Its input is complex valued >x[n], its output complex valued ytilde[n] (both sampled at 100 MHz) ... > >>> The recived signal is time-aligned using fitSignal_120825 from Markus >>> Nentwig. > >... this gives then y[n]. > >>> Increasing the maxstep size decreases the noise floor but does not >>> change NMSE, so I assume it is caused by inband errors. >> >> Max step size in what? The equalizer training? > >No maxstep setting of the continuous-time solver (i.e., the Simulink >simulation setting). I just use "ode45", by the way.
No idea of the significance of ode45.
>>> This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >>> although the noise floor is not perfect but can probably decreases by >>> decreasing maxstep further (in this plot, maxstep=Ts/100). >> >> I'm guessing by the shape of the spectrum that this is a multicarrier >> system? > >No. It's just something like > >x = randn(N,1) + 1i*randn(N,1); >X = fft(x); >X([N*bw+1:N-N*bw-1) = 0; % just ideally bandlimit x to 20 MHz > % (bw is sth. like bw=100MHz/20MHz) >x = ifft(X);
Again, the block diagram doesn't show the FFTs and the bandlimiting, which is a crucial point in understanding what you're doing. You've essentially made a multicarrier system. This is why the spectrum looks like it does. It also means that the fft and ifft contribute to distortion in your system, although I'd expect the effects to be small if they're both floating point.
>> If it is, then I'm not sure what the pulse shaping filter is >> doing in the diagram you linked. > >The DAC outputs rect pulses (zero order hold). >To get rid of the associated images around n*fs you need to shape the >pulses, most prominently just with a lowpass filter. >The more common name is probably reconstruction filter. > >> It shouldn't be there in a >> multicarrier system (unless it's doing tapering or CP insertion? >> There's no way to tell). If it's not a multicarrier system, then >> your spectrum doesn't look very good. You haven't said what sort of >> modulation you're using (that I've noticed, anyway), so it's hard to >> really say anything for certain. > >At this point it's really a simple signal processing system, no >communications or RF. No modulation, no CP etc.
>It's just a random signal, zero-order-held, passed through a filter, >multiplied with a high-frequency sine ("upconversion"), multiplied again >("down conversion"), passed again through a filter (image rejection) and >through an ideal ADC. > >It's really just the canonical I/Q transceiver, something like > >http://upload.wikimedia.org/wikipedia/commons/thumb/1/14/QAM_transmitter.svg/380px-QAM_transmitter.svg.png > >and > >http://upload.wikimedia.org/wikipedia/commons/thumb/5/58/QAM_receiver.svg/500px-QAM_receiver.svg.png > >>> A zoom http://snag.gy/ikAQq.jpg reveals that there is indeed inband >>> distortion. >> >> If the data is random, that's not distortion it's the randomness of >> the data. > >I do not have any noise sources. >Of course the data is generated from a random source but once it is, it >is the deterministic input signal.
The randonmess of the data accounts for why the spectrum is not flat. Unless every in-band bin in the fft/ifft output are identical and you use a flat-top window, you won't see a flat spectrum.
>>> Both filters have a pretty linear phase in the signal band (20 MHz) so I >>> wonder if the error can come from the non-linear phase. >> >> Which filters? > >The transmitters filter and the receive filter). > >>> This >>> construction is as ideal (and unpractical regarding filter orders) as it >>> gets. Furthermore, I when I add the equalizer I can boost it to -45.46 >>> dB - actually nothing. >> >> Previously above you said the EQ provided a 6dB improvement. What do >> you really mean? > >As mentioned above: >1.) I generate x[n] in MATLAB, send it through the Simulink system >2.) I get ytitlde and time-align it to get y[n] >3.) NMSE = 20*log10(norm(x-y)/norm(x)) = -41 dB >4.) If I further equalize y[n] using a FIR filter (as proposed by Markus >in another post) I only get -56.46 dB using the same >20*log10(norm(x-y)/norm(x)) > >The equalizer is just built using a least squares fit on delayed output >samples (post equalizer). But once again, this is not the most important >point. > >> If the EQ really does improve it 6dB as you said earlier, then there >> is linear distortion from somewhere. > >The filter responses probably. > >> It could be filter mismatches, >> it could be a lot of things, but I'm confused as to what you're >> actually doing and the diagram you linked doesn't match your >> description, so it's a bit tough to say. > >I hope I clarified. > > >Thanks >Peter > >
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On Tue, 14 Oct 2014 16:35:47 -0700, Peter Mairhofer <63832452@gmx.net>
wrote:

>On 2014-10-14 15:45, Eric Jacobsen wrote: >> On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net> >> [...] >>> This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >>> although the noise floor is not perfect but can probably decreases by >>> decreasing maxstep further (in this plot, maxstep=Ts/100). >> >> Quick follow-up: That's not a "noise floor", that's a little bit of >> spectral regrowth from the subcarriers (I'm still assuming this is >> multicarrier from the spectrum shape), and it appears to me that the >> regrowth is >75dB down. > >I hope I clarified this in my previous reply. > >So subcarriers and no spectral regrowth because everything is linear.
You do have subcarriers.
>> Not sure how you're measuring SNR, > >20*log10(norm(x-y)/norm(x))
>which is nothing but the definition of NMSE: > >10*log10(mean(abs(x-y)^2)/mean(abs(x)^2))
I don't know where in the process you're taking x or y, and since important details are coming out slowly this doesn't really tell me that much since I don't know what happens in between.
>> but just >> looking at the spectrum is should be a LOT better than 40.72dB. > >And with this I agree (I'd expect -100dB or so), that's the reason for >my question.
No, the green trace in the plot you linked showed some splattering/regrowth at around roughly 75dB. If the blue trace was x and the green trace was y in your NMSE definition, then I would have expected an in-band SNR somewhere around 75-80 dB. If you're including all of the out-of-band stuff in the SNR measurement that'll get worse, naturally. SNR is essentially -NMSE, so there shouldn't be a huge disconnect there.
>> The spurs on the edges of the plot do not appear to be part of the >> signl and I can't tell how high they go. If you're including them in >> the noise power calculation it'll probably affect things negatively. > >I also wondered already where they can come from. >I see no reason for them.
The spectral regrowth and the spurs came from somewhere, and if they're included in the NMSE measurement they'll affect the result. You should be able to look at the spectrum at various points in the signal flow and see what's contributing to the regrowth/distortion.
>As mentioned previously, if I set the maximum step size for the >simulator very very low (Ts/10000) I expect that the green gets down >more and more. I think this is the "noise" due to imperfect integration >in the simulator. > >Peter >
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
Hi Eric,

I just found one potential issue: The zero order hold introduces sinc
distortion. But that's not "the" problem (see below).

Besides that, what is the easiest (even if unphysical) way to get rid of
the sinc distortion?

I tried different things, among "pre emphasis". Suppose "xd" is the
original digital sequence. Then the spectrum should be shaped based on
the first sinc lobe. I tried this:

Fsinc = sinc(linspace(-1, 1, length(xd))).';
% don't correct anything for near-zero values
Fsinc(1:1000) = 1;
Fsinc(end:-1:end-1000+1) = 1;
% DFT spectrum is mirrored
Fsinc = fftshift(Fsinc);
% this is the actual signal to be transmitted
tx = ifft(fft(xd)./Fsinc);

However, the problem even gets worse. Do I do anything wrong here?

(I know in practice a time domain filter would be required. All I want
for now is to eliminate all effects from that).

On 2014-10-14 16:52, Eric Jacobsen wrote:
> On Tue, 14 Oct 2014 16:29:16 -0700, Peter Mairhofer <63832452@gmx.net> > wrote: >> On 2014-10-14 15:40, Eric Jacobsen wrote: >>> On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net> >>> [...] >> >> Oh, they should. As mentioned in the subject this is a Simulink model >> maybe I should have emphasized that again. > > Many of us don't have or use simulink, so don't assume people know > what's in simulink blocks.
But this should not matter too much. It is one of the simplest models you can come up with. Actually, you can do a similar thing in 30 lines of MATLAB code: % oversampling ratio SimFactor = 100; % this is the original x[n] % fs=100 MHz, BW=20 MHz, complex xd = xnbb(:,2); % simulate zero order hold xch0 = repmat(xd.', SimFactor, 1); xch0 = xch0(:); % DAC reconstruction filter for each I and Q branch % corresponds to fs/4=25 MHz in CT [numd_tx,dend_tx] = butter(5, 0.5/SimFactor); xnct_i = filter(numd_tx, dend_tx, real(xch0)); xnct_q = filter(numd_tx, dend_tx, imag(xch0)); % do I/Q upconversion t = (0:1/fs/SimFactor:(length(xnct_q)-1)/fs/SimFactor)'; x_rf = cos(2*pi*fc*t) .* xnct_i - sin(2*pi*fc*t) .* xnct_q; % do IQ downconversion again xnct_down_i = x_rf .* cos(2*pi*fc*t); xnct_down_q = x_rf .* -sin(2*pi*fc*t); % image rejection filter (reject image at 1.2 GHz) % corresponds to fs=100MHz in CT [numd_rx,dend_rx] = butter(5, 2/SimFactor); xnct_down_bb_i = filter(numd_rx, dend_rx, xnct_down_i); xnct_down_bb_q = filter(numd_rx, dend_rx, xnct_down_q); % ideal ADC rx_i = downsample(xnct_down_bb_i, SimFactor); rx_q = downsample(xnct_down_bb_q, SimFactor); % combine signal in digital domain rx = 2*(rx_i +1i*rx_q); % time-align signal [coeff, rx] = fitSignal_120825(xnbb(:,2), rx); rx = rx(:); % show results NMSE = 20*log10(norm(xd-rx)/norm(xd)) plot(20*log10(abs([ fftshift(fft(xd)) , fftshift(fft(rx)) ]))); linspace(-fs/2, fs/2, length(xd)); legend('TX', sprintf('RX: %0.02f dB', NMSE)); It is certainly not equivalent because I have a fixed stepsize and bilinear transform. But the results are similar: -41.30 dB. I plot the the FFT (instead of PSD): http://snag.gy/R0jL1.jpg The weird high frequency lobes are still in the PSD plot but don't show up in the FFT. Regarding sinc distortion: When I remove zero order hold and just use pulses (simulated with "upsample") it does not get significantly better: -43.52 dB.
>> No maxstep setting of the continuous-time solver (i.e., the Simulink >> simulation setting). I just use "ode45", by the way. > > No idea of the significance of ode45.
Since the problems are the same I suspect a general misconception which might be evaluated from the above code too.
>>>> This plot shows the PSD: http://snag.gy/oPHBV.jpg. It looks "perfect" >>>> although the noise floor is not perfect but can probably decreases by >>>> decreasing maxstep further (in this plot, maxstep=Ts/100). >>> >>> I'm guessing by the shape of the spectrum that this is a multicarrier >>> system? >> >> No. It's just something like >> >> x = randn(N,1) + 1i*randn(N,1); >> X = fft(x); >> X([N*bw+1:N-N*bw-1) = 0; % just ideally bandlimit x to 20 MHz >> % (bw is sth. like bw=100MHz/20MHz) >> x = ifft(X); > > Again, the block diagram doesn't show the FFTs and the bandlimiting, > which is a crucial point in understanding what you're doing.
It is not part of the system. I just have a signal with these properties and is the input signal to the system. I have the signal. I don't even use the code above, it was shown as "pseudocode" to understand what it looks like.
> You've essentially made a multicarrier system. This is why the > spectrum looks like it does.
No, I create a random signal. But of course you can feel free to interpret it as a discrete-time representation of a multicarrier signal where each carrier is arbitrarily I/Q modulated ...
> It also means that the fft and ifft contribute to distortion in your > system, although I'd expect the effects to be small if they're both > floating point.
Why? There is no FFT/IFFT involved here. Again, I am not doing OFDM et.al. and do not calulate my error based on some modulated symbols. It is nothing more but an arbitrary, bandlimited x[n], converted to x(t) and mixed to RF and back.
>> [...] >> I do not have any noise sources. >> Of course the data is generated from a random source but once it is, it >> is the deterministic input signal. > > The randonmess of the data accounts for why the spectrum is not flat.
Of course, it should not be flat. It should just be bandlimited. Maybe the PSD is not the perfect plot to show. Therefore I changed it to FFT plot.
> Unless every in-band bin in the fft/ifft output are identical and you > use a flat-top window, you won't see a flat spectrum.
which I don't want ;-) I want the green and blue curve to match :-) Thanks, Peter
Hi Eric,

On 2014-10-14 17:06, Eric Jacobsen wrote:
> On Tue, 14 Oct 2014 16:35:47 -0700, Peter Mairhofer <63832452@gmx.net> > wrote: >> On 2014-10-14 15:45, Eric Jacobsen wrote: >>> On Tue, 14 Oct 2014 14:41:17 -0700, Peter Mairhofer <63832452@gmx.net> >> [...] >>> Not sure how you're measuring SNR, >> >> 20*log10(norm(x-y)/norm(x)) > >> which is nothing but the definition of NMSE: >> >> 10*log10(mean(abs(x-y)^2)/mean(abs(x)^2)) > > I don't know where in the process you're taking x or y, and since > important details are coming out slowly this doesn't really tell me > that much since I don't know what happens in between.
I have an x "send" it through my model and "receive" y. *Then* in MATLAB I align y and perform the calculation above. I added a short MATLAB code in my previous response which should do a similar thing and shows similar results. From there it should be more clear.
>> And with this I agree (I'd expect -100dB or so), that's the reason for >> my question. > > No, the green trace in the plot you linked showed some > splattering/regrowth at around roughly 75dB.
I think this is noise which comes from imperfect integration in the simulator (it is solving the differential equations numerically). The fact that it is not regular may be caused by variable step size which give some frequency modulation of the error. In any case, if I reduce the maximum step size this "floor" decreases but NMSE stays the same. This can also be seen in the MATLAB equivalent code where this "splattering/regrowth" does not show up at all.
> If the blue trace was x > and the green trace was y in your NMSE definition,
which is the case
> then I would have > expected an in-band SNR somewhere around 75-80 dB.
I agree, me too, but that's not the case.
> If you're > including all of the out-of-band stuff in the SNR measurement that'll > get worse, naturally.
Yes, but not by 33-40 dB, right?
> SNR is essentially -NMSE, so there shouldn't be a huge disconnect > there.
I agree.
> [...] > The spectral regrowth and the spurs came from somewhere, and if > they're included in the NMSE measurement they'll affect the result. > > You should be able to look at the spectrum at various points in the > signal flow and see what's contributing to the regrowth/distortion.
See above - I think these are simulator artefacts. No regrowth/distortion with MATLAB code but same error (-41 dB) Peter
On Tuesday, October 14, 2014 4:29:16 PM UTC-7, Peter Mairhofer wrote:
> Hi Eric, >
...
> > No. It's just something like > x = randn(N,1) + 1i*randn(N,1); > X = fft(x); > X([N*bw+1:N-N*bw-1) = 0; % just ideally bandlimit x to 20 MHz > % (bw is sth. like bw=100MHz/20MHz) > x = ifft(X); >
...
> Peter
Peter "something like" is a little sketchy. How do you assure that the input signal is cyclic in the data duration passed to fitSignal_120825? How do you assure that there is no start-up transient included in the data block you analyze? Dale B. Dalrymple