• 0

Analog Discovery 2 as Software Defined Radio?


Question

Hi!

Since I've been doing a lot of stuff with SDR for the past 2 years, I was wondering, if it is possible to use the AD2 with any SDR software. The Waveforms SDK only allows to record float values to a file, if I understood correctly, so I would have to save them and convert them before usage. It would be nice though, to make a FIFO pipe to some other software like gnuradio, gqrx or SDR#. Thanks to the 14 bit ADC/DAC it would be a very useful SDR device.

Does anybody of you have an idea, of how to implement this? Since we can use the AD2 to play audio, the easiest way would be to create a virtual sound card, piping the whole spectrum (Waveforms does it in spectrum view, but without demodulation possibilities), because those can be used in any SDR software.

Thanks in advance!

Link to post
Share on other sites

Recommended Posts

  • 1

How to install (I'm using Ubuntsu and GRC 3.7.11 with WX GUI.)

at "gr-AD2_AnalogXx_Xxxxxx" directory

$ mkdir build ↵
$ cd build ↵
$ cmake ../ ↵
$ make ↵
$ sudo make install ↵

wxgui_.... blocks are not mine, installed with GRC 3.7.11.

Before using my blocks, you should be install Waveforms and dwf (from pip)

Link to post
Share on other sites
  • 0

Hello,

The recording to file is just an example script.

The WaveForms SDK provides functions to control, send and receive samples... You can do whatever you need with received samples, you can process it as you need for your task. The functions allow to generate custom periodic arbitrary waveforms or stream/play samples too.

Link to post
Share on other sites
  • 0

@fusionimage,

64 bits/sample is overkill.  Very few operational systems (if any) provide that much fidelity.  Even the USRP itself, the very hardware that helped GnuRadio get off the ground, only starts with 16-bit samples.  Sure, they've got an FPGA that does fun things with it and spits out 64-bit samples, but their sensor didn't start with 64-bit samples.  Gosh, for some applications, even the 16-bit sampler is still way more than you need.  For example, here's an FPGA core that can turn an FPGA into an FM transmitter using only 1-bit sampling.  It operates by treating the FPGA board as an antenna, and then using the GPIO from the FPGA to "transmit" out the antenna.  Since GPIO can only be a one or a zero, the fact that this works at all should be ... instructive.  (If not amazing--transmitting at commercial FM frequencies from an FPGA running at 80MHz?)

In a similar fashion, it's often easier to build hardware that only handles real signals and samples--complex I/Q sampling is easier to do via digital signal processing than it is to do in analog processing. There's just this sneaky amount of current that always seems to sit at DC that can be really hard to get rid of.  It biases signals and creates annoying artifacts.  For this reason, it's often easier to perform analog sampling using real signals rather than complex I and Q.

GnuRadio can handle 1 bit samples.  It can handle 8-bit samples.  It can handle 10, 12, or 16 bit samples.  Look through that documentation a little harder.  It's all there.

Dan

Link to post
Share on other sites
  • 0

ok, so how would you pipe a datastream to gnuradio? if you know gnuradio, you also should know, that it is used for DSP. i don't want the ad2 to stream 64bits per sample, this is just what gnuradio uses to save and read data to or from files by default. it doesn't mean that you must have a 32bit adc/dac for that

i didn't even talk about transmission and neither about commercial FM broadcast frequencies. as a licenced ham radio operator i am allowed to transmit on many different bands, but i just would like to receive shortwave with the ad2 because of the 12bit adc. the simpliest way for me would be a fifo pipe that can be read by gnuradio, but i have no idea how to do that. since i am not really familiar with python, i can't even include the ad2 sdk directly to gnuradio, what would make the usage even easier, since it uses python scripts too

 

edit:

"A floating point data stream is saved as 32 bits in the file, one after the other. A complex signal has 32 bits for the real part and 32 bits for the imaginary part."

so there are 64 bits per sample, just written/read one after each other

sure you are right, that i don't need 64 bits of data, but i don't even know how to get the 12 bits into gnuradio ;)

http://gnuradio.org/redmine/projects/gnuradio/wiki/FAQ#What-is-the-file-format-of-a-file_sink-How-can-I-read-files-produced-by-a-file-sink

Edited by fusionimage
Link to post
Share on other sites
  • 0

Just a little background for any non-GnuRadio reader: GnuRadio consists of a library of C++ modules. It uses python to string those modules together, and has a beautiful GUI to help you place modules within your design, adjust their inputs and outputs, and adjust their parameters.  The GUI is what creates a Python program, which connects the signal processing flow graph together, and then calls its processing engine.  The guts of GnuRadio, however, is all in C++.  In a similar fashion, everything that needs to run fast (such as needing to run at 1Msps) is written in C++.  There are a lot of good, fast, C++ functions out there--many which even use the vector capabilities of modern processors.  Preference should always be to use a library capability if you can find one.

So, .... how?  Start with looking through the library routines for the ones you want.  Often the GnuRadio library routines have several variants, differing by the data types they are using.  Look for one that handles 12-bit integers, or perhaps instead look for one that handles 16-bit integers for which you could stuff 12-bit integers into it.  You'll also want your first stage to handle real values (not complex).

If you can't find the function you want/need, then build it within C++.  GnuRadio calls this an "Out-Of-Tree" module, so you can use that to look up how to do this.  Indeed, you are likely to need a device specific ingest program no matter what ADC you are reading from.  The goal of your C++ module should be to 1) communicate with your device (the AD2), 2) get your data format right (does it produce packed 12-bit data?  unpack it if so and place it in the top 12 bits of a 16-bit value--you can also go straight to floating point here), and 3) (if possible) to reduce your data rate as much as possible.

Once you get it running, I'm sure the GnuRadio program would appreciate it if you gave your AD2-GnuRadio ingest routine back.  You might be surprised at what others did with it, once it became open source--should you choose to go this road.

Dan

Link to post
Share on other sites
  • 0

Looks like you might need to do some reading.  :D

You can find the Waveforms SDK manual here.  Within it, you'll find that the function FDwfAnalogInFrequencyInfo can be used to get the minimum and maximum sampling rates, FDwfAnalogInFrequencySet can be used to set the sampling frequency, and FDwfAnalogInFrequencyGet can be used to get the current sampling frequency. 

You can find the GnuRadio tutorial on how to build an "Out of Tree" module here.

Perhaps someone else on the forum, who knows more about the actual bandwidth, can pipe in regarding your bandwidth question.  I'd answer but ... I don't have an AD2, and so I'm not the one most familiar with it.  (Sorry.)  I just happen to have done a bit of work with GnuRadio--hence my comments above.

Dan

Link to post
Share on other sites
  • 0

i think, this are exactly the functions i was looking for. since they are not used in the analogin_sample.py and analogin_shiftscreen.py, i didn't think about, that other functions could do the job.....

thx for the grc oot link. this will be the final part. first i need to understand the sdk :D

Link to post
Share on other sites
  • 0

Hello,

You can find information about the analog bandwidth of AD2 on the following page: https://reference.digilentinc.com/reference/instrumentation/analog-discovery-2/reference-manual#scope_spectral_characteristics

For lower sample rate than 100MHz set filterDecimate with FDwfAnalogInChannelFilterSet to avoid damping of the default filterAverage option.

Link to post
Share on other sites
  • 0

Can't promise I will gain traction, but if I do, I'll post back here.  I have no experience with GnuRadio beyond what I saw presented at a Linux User Group.  I'm in the "Google-foo" phase.

Chris

Link to post
Share on other sites
  • 0

If I understand what you want to do correctly, you want to build an "Out-Of-Tree" module for GnuRadio that accepts data from the AD2 and sends it to GnuRadio.  It's not too hard to do, you just need to know the interface to AD2, and the interface to GnuRadio, and you plug them together, right?  :D  Specifically, I think GR has a Sync type of module, that then drives the clock rate of everything following it.

Dan

Link to post
Share on other sites
  • 0

Let's consider the simple case of a host with a single Analog Discovery 2 connected.  Let's assume that we're only interested in using one analog input and one analog output on that Analog Discovery 2.  We would need to write some C++ code to:

  • implement a "Digilent Analog Discovery 2 Analog Input" class that inherits from GnuRadio's gr::sync_block class and provides an I/O signature with one 16-bit integer output
  • implement a "Digilent Analog Discovery 2 Analog Output" class that inherits from GnuRadio's gr::sync_block class and provides an I/O signature with one 16-bit integer input

These classes would use the Waveforms API (/usr/include/digilent/waveforms/dwf.h, /usr/lib/libdwf.so) and roughly follow its accompanying C-language example source files (/usr/share/digilent/waveforms/samples/c) to implement the interface contract that GnuRadio expects of gr::sync_block classes.

As @[email protected] mentioned, we'd package want to build & package these blocks as an Out-of-Tree Module for GnuRadio that we could then load from a "stock" GnuRadio installation.

[1] https://wiki.gnuradio.org/index.php/OutOfTreeModules#Sources_and_sinks

[2] https://gnuradio.org/doc/doxygen/classgr_1_1sync__block.html

[3] https://gnuradio.org/doc/doxygen/classgr_1_1io__signature.html

Edited by clf
*integer* input
Link to post
Share on other sites
  • 0

@attila and the Digilent crowd,

1) What license is the Waveforms API and example code licensed under?

2) Are you OK with third-parties creating & releasing under an MIT-style license (a) a C++ language port of the Waveforms API and/or (b) a GnuRadio adapter for the Waveforms hardware, with the understanding that these might incorporate Digilent's published source code?

Thanks in advance,

Chris

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now