Questions from a beginner

Discussions related to embedded firmware, driver, and user mode application software development
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

A more direct question:

I was looking at: https://libraries.io/github/Nuand/Simul ... AB-bladeRF and noted the GitHub project page was gone. The Simulink-MATLAB-bladeRF code that allows you to create a "blockset" using the make.m command isn't there. I tried this in MATLAB and there is no such command. Another words the Toolbox can't be created in the Simulink Library Browser as stated in the linked page.

The only thing I found was what I already had and that's this page: https://github.com/Nuand/bladeRF/tree/m ... ngs/matlab which I've already built (mentioned above).

jom
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

I still can't find any information on creating the MATLAB Toolbox blockset in the Simulink Library Browser as stated in the link I gave in my last post. If no one knows where else could I find info?

Nonethless I've got the rx_gui working in MATLAB which is great.

I'm wondering, however, why there is always a tone dead center of the band I'm looking at. I saw this when I got SDR-Radio working last week and now I see it in the MATLAB gui. No matter where I put the RX input I get this -50 dB (dBm or dBFS?) spur right in the center of the FFT output. Why is that? Is the TX on and outputting a tone that is leaking into the RX or what?

Right now I also have a controlled synthesizer output going into the RX and it is clearly "beating" against this tone as I'm getting mixer spurs centered around it. Shown below. The Synth input is 1099.5MHz, 1100MHz is this odd tone and just above that is what I call a "mixer tone".

Image

If I turn off the Synth all that is left is the center tone...and like I said it stays there no matter what I make the RX center frequency.

Anyway, at least I got this working. Cool! It's also nice to be able to ask about something I'm at least familiar with...for once. :lol:

Thanks

jom
jynik
Posts: 455
Joined: Thu Jun 06, 2013 8:15 pm

Re: Questions from a beginner

Post by jynik »

That's not a tone or spur -- that's the result of integration gain over a DC offset. This is common with direct conversion receivers.

You can read more here:
https://github.com/Nuand/bladeRF/wiki/D ... n#overview

Note that playing with the DC offset I and Q values will allow you to manipulate this. Look at the "scope" XY view and you'll see the I and Q DC offset changing.
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

OK, thanks...I should have known that but I'm so used to Superhets I didn't catch that. I'll see if I can figure out how to play with the offsets to adjust.

Also, any thoughts on the MATLAB Toolbox blockset issue I asked about. I know you are busy but I don't know how to proceed with that.

Thanks again! :D

jom
jynik
Posts: 455
Joined: Thu Jun 06, 2013 8:15 pm

Re: Questions from a beginner

Post by jynik »

Hi jom,

I'm a little confused by what you're asking about the Simulink block set. Maybe things will become clearer to both of us with the following notes:

1. Simulink-MATLAB-bladeRF is deprecated, so you can ignore this project entirely. MATLAB and Simulink support was entirely re-written using the loadLibary() interface, and this supersedes this. Thus, there is no more make.m or anything pertaining to generating blocks.
2. Simulink support is now provided as MATLAB System Object, implemented in this file: https://github.com/Nuand/bladeRF/blob/m ... Simulink.m
2a. A System Object essentially exposes a Simulink block interface atop of some MATLAB code. The aforementioned file is just glue logic "hooking up" simulink to the bladeRF MATLAB interface.
3. The only thing to "build" now is the Thunk files -- this is a dynamic library wrapper around libbladeRF that exposes API functions to the MATLAB code.

Hopefully that makes a little more sense.
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

Thanks for the reply!
jynik wrote:Hi jom,
1. Simulink-MATLAB-bladeRF is deprecated, so you can ignore this project entirely. MATLAB and Simulink support was entirely re-written using the loadLibary() interface, and this supersedes this. Thus, there is no more make.m or anything pertaining to generating blocks.
I was trying to follow the guide here: https://libraries.io/github/Nuand/Simul ... AB-bladeRF I had assumed that it was "up to date". There were some broken links in the section "Build/Install instructions for Microsoft Windows". That's where my confusion came from.
2. Simulink support is now provided as MATLAB System Object, implemented in this file: https://github.com/Nuand/bladeRF/blob/m ... Simulink.m
2a. A System Object essentially exposes a Simulink block interface atop of some MATLAB code. The aforementioned file is just glue logic "hooking up" simulink to the bladeRF MATLAB interface.
I'll take a look at the file in MATLAB and see what I can figure out what you mean here.
3. The only thing to "build" now is the Thunk files -- this is a dynamic library wrapper around libbladeRF that exposes API functions to the MATLAB code.
I'm not sure what a Thunk file is but I'll see what I can find.

Thanks!

jom
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

I'm still having issues with my bladeRF device and that IQ issue. I must not understand what is going on here as well as I should.

First of all, I tried adjusting the IQ offset using the MATLAB gui interface and only got the tone down to -60dB or so. I don't know if I can do better nor do I know if that is enough to prevent the distortion I'm seeing. It's not my signal generator as I checked it out on my spectrum analyzer. I either don't know how to adjust this IQ issue properly, I've got another setting that is creating some other distortion internally (such as too much VGA gain), the bladeRF MATLAB gui can't do what I need to do to fix this or there is something wrong with the board I'm using.

This part of the forum may not be the proper place for this issue so I apologize in advance...

Again, thanks for all of the help. :D

jom
bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: Questions from a beginner

Post by bpadalino »

-60dB worth of image rejection is pretty good. It's not great if you're doing SSB, but do you need more than 60dB of SNR to get your signal across?

I am not sure if you have an issue with DC offset or IQ imbalance, but try also looking at the time domain samples.

What exactly is the issue you are trying to solve and do you know how good is good enough?

Brian
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

To keep you from having to read the whole thread I'll explain: What I'm trying to do is simply input a tone (using my own synthesizer) and observe it using the MATLAB gui. I've noticed when I observe the spectrum results there is always a tone dead center of whatever band I'm looking at (in and around 1 GHz mostly). jynik explained it could be the IQ or DC offsets. Not knowing the radio completely I just used the IQ adjustments allowed in the gui to lower the tone. However, I still get these odd...what I'd call and what looks like, inter-modulation or an AM-like signal. See the spectrum picture I posted on the last page of this thread.

Thanks for the input! :)

jom
bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: Questions from a beginner

Post by bpadalino »

Are you trying to use the device as a spectrum analyzer expecting spectrum analyzer like results?

I guess I go back to the original question - what are you trying to solve and how good is good enough? You answered the first part - you want the tones to go away. If you want the DC spike in the middle to go away, then remove the long term average mean from the input samples before you take the FFT. If you want the conjugate image to go away, then you will need to find the error in magnitude and phase between the in-phase and quadrature signals, compensate, and then send it into the FFT.

I hope this makes sense for you. Since it's all in MATLAB, and the MATLAB code is freely available, doing these two things before displaying the FFT is just an exercise in implementing that algorithm.

Good luck!
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

bpadalino wrote:Are you trying to use the device as a spectrum analyzer expecting spectrum analyzer like results?
Yeah, actually (and possibly mistakenly) I did. However, the question "what is good enough?" wasn't really relevant to me. I just wanted to get some of the available software (in this case MATLAB) to work and see what I could do with it. The original intention of this thread was to find out about the software surround this device. I have a difficult time figuring that all out (I guess that's what they call it "abstraction"..heh) hence the thread.
If you want the DC spike in the middle to go away, then remove the long term average mean from the input samples before you take the FFT. If you want the conjugate image to go away, then you will need to find the error in magnitude and phase between the in-phase and quadrature signals, compensate, and then send it into the FFT.
Can I then assume these settings are already in play as a default (ie the long term average)? If so, then I can then adjust them accordingly....I hope. That would make sense.
Since it's all in MATLAB, and the MATLAB code is freely available, doing these two things before displaying the FFT is just an exercise in implementing that algorithm.
I did use the offset adjustments in the gui but that did not work. Then again, I'm sure there are many more interface code functions I do NOT know about (such as the aforementioned long-term average) I can still use...I think. :)

The real test for me after this is do more with that Pothos software...which I've had trouble deciphering...although I need to spend more time with.

Thanks again!

jom

PS: I should probably point out my true goal here is to use this radio as part of my master's degree thesis which is in EE (communications).
bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: Questions from a beginner

Post by bpadalino »

There aren't any of the IQ corrections or long term DC averaging done in MATLAB. Feel free to modify the code. It should be super simple to follow - it isn't that difficult that all.

The corrections worked but they aren't perfect. Getting 60dB worth of image rejection for a direct downconversion receiver is usually plenty good enough. DSP can take out more if you really need it, but we don't implement anything like that.

While I know you said you aren't interested in what's good enough - you should be, especially as an MS student. Trying to attain perfection will get you nowhere. The IQ correction did exactly what it was supposed to with the precision it was allowed.

I guess my last piece of advice is to stop fretting over what you see in the PSD of the signal and worry about getting your information across your channel.
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

I guess I don't understand exactly what is going on. It seems to me if you put in an external tone at 1.01 GHz the FFT should show me a tone at 1.01 GHz not a bunch of side band distortion. I do have the habit of looking at radio receivers like I do spectrum analyzers however. It didn't behave like I thought and I don't know why this should be the case. I just felt that having so many tones at such a high level relative to my input was odd...at least in my experience.
While I know you said you aren't interested in what's good enough - you should be, especially as an MS student. Trying to attain perfection will get you nowhere.
Of course I'm interested in "good enough". I deal with it every day. I'm struggling (just like I thought I would) with the software interfaces which is not my strength (hence the thread). So for this simple set up I just wanted to see if I could get the radio to work (using MATLAB in this case) and have it respond like I think it should (which could be admittedly incorrect) with a simple tone going in. Of course, what I think it "should" based on my experience may not be correct.
There aren't any of the IQ corrections or long term DC averaging done in MATLAB.
If that is the case I'm not sure how I was able to make adjustments in the MATLAB gui. Maybe you are speaking of something else. :?:

There is a lot to learn for me and I apologize for the questions as it seems I might have ruffled some feathers here. I guess I'm frustrated as well but that's OK. Even MATLAB is giving me trouble with the "Thunk" files as it doesn't seem to be generating correctly...at least that is my perception (which, again, could be incorrect). I need to find more examples of what people are doing with this radio using the tools available. So far it's been rather sparse...

Thanks again! :)

jom
bpadalino
Posts: 303
Joined: Mon Mar 04, 2013 4:53 pm

Re: Questions from a beginner

Post by bpadalino »

The software is just in the bladerf_fft M file. Specifically, for plotting the FFT, the relevant lines are here. It's pretty simple. If you can't figure out how to remove DC here, then I am not sure I can help you much at all without doing all the work for you.

Read up on direct conversion RF receivers and the effects of IQ imbalance, specifically magnitude and phase imbalances as well as the DC offset problem for direct conversion receivers.

These radios are not spectrum analyzers. Sometimes it may take intuition or extra troubleshooting to figure out what signal is there and what may be a spur, image or some other type of anomaly.

Good luck!
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

bpadalino wrote:The software is just in the bladerf_fft M file. Specifically, for plotting the FFT, the relevant lines are here. It's pretty simple. If you can't figure out how to remove DC here, then I am not sure I can help you much at all without doing all the work for you.
Just to clarify I never once said I wanted anyone to "do all the work for me". :D

The task is a good one but it is not "pretty simple". Not for me. I've looked over the code you referred to and I can estimate that I can follow about 30% of it. I've had to look up many of the code snippets at the MATLAB help site. You just have to slog through it. Also, since it looked similar to "C" code and I found some vids on OOP and brushed up on "methods, properties" etc as best I could.
Read up on direct conversion RF receivers and the effects of IQ imbalance, specifically magnitude and phase imbalances as well as the DC offset problem for direct conversion receivers.
I'm in the process of doing just that. I appreciate the links and info on Github.
These radios are not spectrum analyzers
Actually I should have said that SA's are radios nothing but radios in a sense. SDRs can be used for such a thing but it is possible that given SA's are used as test equipment and have tough specifications a superhet type receiver might be a better choice than direct conversion in that case...but I digress.
Good luck!
Thanks...I'm gonna need it. :o

jom
Post Reply