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 »

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
jom
Posts: 23
Joined: Tue Jul 19, 2016 10:08 pm

Re: Questions from a beginner

Post by jom »

Hello yet again...just a question about the MATLAB "thunk" .dll file: I'm still having difficulty figuring this stuff out so I'll just ask:

What is the purpose again of the libbladeRF_thunk_pcwin64.dll file? You already have the bladeRF.dll so why the extra library file?

Thanks

jom
YenPang
Posts: 3
Joined: Wed Mar 21, 2018 7:59 am

Re: Questions from a beginner

Post by YenPang »

jom wrote: Wed Aug 03, 2016 10:55 am I moved the "libusb-1.0.20", "pthreads-w32" and "bladeRF" to the default locations. The "bladeRF" does not have a "lib" folder after I installed it in the default location but I don't know why CMake is looking for it.

As noted in the output CMake could not load "D:/Program Files/PothosSDR/lib/libusb-1.0.dll". The file is there so I don't know why it couldn't load. Does this relate to the "libusb-1.0.20" it is using in the other path? In fact, I don't even know how CMake knows Pothos was placed on my "D" drive. :?:

FX3_SDK_PATH is blank and I don't know what to put there anyway.

Before I ran this above I deleted the cache and deleted what was in the "build" directory.
Hi Jom,

I am a new beginner encountering almost the same problems you got before.

I also followed the same process listed on the github wiki page and I got stuck in the configuration of Cmake.

Cmake looked for the lib folder of the bladeRF directory and Cmake also couldn't find the pkgconfigure.

FX3_SDK_PATH is blank as you got before.

Could you let me know how you solve these problems?

Thank you very much.

YenPang
User avatar
rtucker
Posts: 77
Joined: Sun Jan 25, 2015 10:38 am

Re: Questions from a beginner

Post by rtucker »

Greetings...

It is okay for FX3_SDK_PATH to be blank, as that is only needed if you're building without libusb. Also, there is no Windows equivalent to PkgConfigure, so that warning is normal.

Make sure that:
  • LIBPTHREADSWIN32_PATH is pointed at the pthreads-win32/pthreads.2 directory, where you've built the modified pthreads-win32
  • LIBUSB_PATH is pointed at the libusb-1.0.21 directory
  • ENABLE_BACKEND_LIBUSB is selected
  • ENABLE_BACKEND_CYAPI is NOT selected
Then hit "Configure" and it should be okay (with some red values); hit "Configure" again and it should be all okay with no red values.

If this doesn't work, let us know what errors you're getting and include a screenshot of the CMake window, and I'll take a look.
Rey Tucker (she/her)
Systems Engineer, Nuand LLC
Rochester, NY, USA

#WontBeErased
YenPang
Posts: 3
Joined: Wed Mar 21, 2018 7:59 am

Re: Questions from a beginner

Post by YenPang »

Hi Rey,

Thank you for your reply.

I did the configuration again by following your suggestion.
When I did the first configuration, it shows the result as below.
CMake config1.PNG
It didn't show "LIBPTHREADSWIN32_PATH" until I checked the value of "ENABLE_BACKEND_LIBUSB". And the result of the second configuration is like the photo below.
CMake config2.PNG
And I continued pressing configure and got the results of the third one.
CMake config3.PNG
The configuration contained errors which makes me not be able to generate the executable file.

I installed "bladeRF Windows" and placed libusb-1.0.20 and pthreads-win32 at C:/Program Files (x86)/.
Is it because of the difference with libusb-1.0.20 and libusb-1.0.21?
What should I modify the pthreads-win32? I only modified the pthread.h by adding #define HAVE_STRUCT_TIMESPEC and #define PTW32_ARCHx64 near the top (I didn't see the include guard in it).
Is this the reason causing me stop?

Thank you again for your help.

YenPang
User avatar
rtucker
Posts: 77
Joined: Sun Jan 25, 2015 10:38 am

Re: Questions from a beginner

Post by rtucker »

When you say you installed "bladeRF Windows", do you mean you downloaded and installed a bladeRF-win-installer-*.exe file (available from http://nuand.com/installers.php)? If so, then that's all you need to do -- you don't need to install libusb or pthreads-win32, or compile libbladeRF, as it's already done. (I'm updating the Wiki page to clarify this.)

If you do need to build libbladeRF, then:

What is in the C:\Program Files (x86)\libusb-1.0.20\ and C:\Program Files (x86)\pthreads-win32\ directories?

Here's my CMake window, as well as the contents of my LIBUSB_PATH and LIBPTHREADSWIN32_PATH directories:
Screenshot_win10-1802eval_2018-03-22_00.png
Screenshot_win10-1802eval_2018-03-22_01.png
Rey Tucker (she/her)
Systems Engineer, Nuand LLC
Rochester, NY, USA

#WontBeErased
Post Reply