This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
university:tools:m2k:tutorials:buildingaradiowithm2k [31 Jan 2020 16:15] – [GRC Flowgraph] Adrian Suciu | university:tools:m2k:tutorials:buildingaradiowithm2k [26 Feb 2020 12:34] – replace gr-iio with gr-m2k Teo Perisanu | ||
---|---|---|---|
Line 49: | Line 49: | ||
=====Software===== | =====Software===== | ||
GNU Radio is a free and open-source software development toolkit that provides signal processing blocks to implement software radios. GNU Radio Companion (GRC) is a graphical tool for creating signal flow graphs and generating flow-graph source code. | GNU Radio is a free and open-source software development toolkit that provides signal processing blocks to implement software radios. GNU Radio Companion (GRC) is a graphical tool for creating signal flow graphs and generating flow-graph source code. | ||
- | GNU Radio can be extended with own functionality and blocks using OutOfTreeModules. gr-iio is a module containing | + | GNU Radio can be extended with own functionality and blocks using OutOfTreeModules. gr-m2k is a module containing blocks for interfacing with ADALM2000. |
- | Creating a flowgraph in GRC, using GNU Radio 3.7, is an easy and fast solution. There are two possible approaches: | + | Creating a flowgraph in GRC, using GNU Radio 3.8, is an easy and fast solution. There are two possible approaches: |
* Creating a new out-of-tree module. Please check the available OutOfTreeModules [[https:// | * Creating a new out-of-tree module. Please check the available OutOfTreeModules [[https:// | ||
- | * Integrating the ADF4350 block with gr-iio | + | * Integrating the ADF4350 block with gr-m2k |
- | All steps for integrating ADF4350 with gr-iio will be further explained. | + | All steps for integrating ADF4350 with gr-m2k will be further explained. |
==== ADF4350 block ==== | ==== ADF4350 block ==== | ||
- | Controlling the radio implies controlling the output voltage frequency of ADF4350. A GRC block, integrated with IIO blocks, that controls the frequency can be created. no-OS provides a driver for ADF4350 that simplifies the work. This driver communicates using SPI. In the following steps we are going to create a GRC block for gr-iio that uses libm2k communication segment integrated with no-OS drivers. | + | Controlling the radio implies controlling the output voltage frequency of ADF4350. A GRC block, integrated with M2k blocks, that controls the frequency can be created. no-OS provides a driver for ADF4350 that simplifies the work. This driver communicates using SPI. In the following steps we are going to create a GRC block for gr-m2k that uses libm2k communication segment integrated with no-OS drivers. |
- Install libm2k. Instructions can be found [[https:// | - Install libm2k. Instructions can be found [[https:// | ||
- | - Compile the gr-iio blocks for your PC. Check the steps [[https:// | + | - Compile the gr-m2k blocks for your PC. Check the steps [[https:// |
- Download the ADF4350 driver from [[https:// | - Download the ADF4350 driver from [[https:// | ||
Line 72: | Line 72: | ||
Project structure: | Project structure: | ||
- | * gr-iio | + | * gr-m2k |
* grc | * grc | ||
- | * iio_adf4350_sink.xml | + | * m2k_adf4350_sink.block.yml |
- | * include/gnuradio/ | + | * include/m2k |
* adf4350_sink.h | * adf4350_sink.h | ||
* lib | * lib | ||
Line 85: | Line 85: | ||
* adf4350_sink_impl.cc | * adf4350_sink_impl.cc | ||
* swig | * swig | ||
- | * iio_swig.i | + | * m2k_swig.i |
**Create the inclusion header** | **Create the inclusion header** | ||
- | Create // | + | Create // |
Add this file in the corresponding CMake file. | Add this file in the corresponding CMake file. | ||
Line 96: | Line 96: | ||
... | ... | ||
adf4350_sink.h | adf4350_sink.h | ||
- | DESTINATION ${GR_INCLUDE_DIR}/ | + | DESTINATION ${GR_INCLUDE_DIR}/ |
In the make function add as parameters the URI and all attributes from the adf4350_init_param structure (23 attributes) found in the driver. This way they could be change from GRC without hard coding them. | In the make function add as parameters the URI and all attributes from the adf4350_init_param structure (23 attributes) found in the driver. This way they could be change from GRC without hard coding them. | ||
Line 104: | Line 104: | ||
In this part we are going to integrate libm2k with a no-OS driver. For more information please check this [[https:// | In this part we are going to integrate libm2k with a no-OS driver. For more information please check this [[https:// | ||
- | Create // | + | Create // |
- | Create a drives directory in gr-iio/lib and add the ADF4350 driver. Add both source files in the corresponding CMake file. | + | Create a drives directory in gr-m2k/lib and add the ADF4350 driver. Add both source files in the corresponding CMake file. |
- | list(APPEND | + | list(APPEND |
... | ... | ||
adf4350_sink_impl.cc | adf4350_sink_impl.cc | ||
Line 115: | Line 115: | ||
#include < | #include < | ||
- | ADF4350 block will receive a message from an IIO Attribute Updater | + | ADF4350 block will receive a message from a QT GUI block. The message contains the value of the frequency. |
The adf4350_sink_impl class has to implement the class constructor and a method (// | The adf4350_sink_impl class has to implement the class constructor and a method (// | ||
In the source file (// | In the source file (// | ||
- | libm2k:: | + | libm2k:: |
m2k_spi_init m2KSpiInit; | m2k_spi_init m2KSpiInit; | ||
m2KSpiInit.clock = 0; | m2KSpiInit.clock = 0; | ||
Line 140: | Line 140: | ||
* pass the value to the driver, in order to set the output frequency of ADF4350 | * pass the value to the driver, in order to set the output frequency of ADF4350 | ||
- | | + | pmt:: |
- | | + | |
| | ||
- | if (!is_dict(pdu)) | + | if (!is_pair(pdu)) |
- | throw std:: | + | throw std:: |
+ | } | ||
| | ||
- | | + | |
+ | std::string skey = pmt:: | ||
| | ||
- | | + | |
- | adf4350_out_altvoltage0_frequency(adf4350_device, freq); | + | long long frequency; |
+ | | ||
+ | std::string sfreq = pmt::symbol_to_string(freq); | ||
+ | frequency = std::stoll(sfreq); | ||
+ | adf4350_out_altvoltage0_frequency(d_adf4350_device, frequency); | ||
+ | std::cout << " | ||
+ | } | ||
**Create python bindings** | **Create python bindings** | ||
- | In swig directory is a file called //iio_swig.i//. Include the block' | + | In swig directory is a file called //m2k_swig.i//. Include the block' |
%{ | %{ | ||
... | ... | ||
- | # | + | # |
%} | %} | ||
... | ... | ||
- | | + | |
... | ... | ||
- | | + | |
**Create the GRC component** | **Create the GRC component** | ||
- | GNU Radio 3.7 uses xml files for creating GRC blocks. Create a file //iio_adf4350_sink.xml// in the //grc// directory. This file will describe how the GRC block should look like. | + | GNU Radio 3.8 uses yml files for creating GRC blocks. Create a file //m2k_adf4350_sink.block.yml// in the //grc// directory. This file will describe how the GRC block should look like. |
Add all parameters using the following format: | Add all parameters using the following format: | ||
- | <param> | + | |
- | <name> | + | |
- | <key> | + | |
- | <value> | + | |
- | | + | hide: part |
- | <hide>part</ | + | |
- | </ | + | |
This block is a sink for messages, not streams. To specify this create the following tag: | This block is a sink for messages, not streams. To specify this create the following tag: | ||
- | | + | |
- | < | + | |
- | < | + | id: msg |
- | <optional> | + | |
- | </ | + | |
**Build the new created block** | **Build the new created block** | ||
- | cmake . | + | |
+ | | ||
make | make | ||
sudo make install | sudo make install | ||
- | cd .. | + | cd ../.. |
sudo ldconfig | sudo ldconfig | ||
- | The source code can be found on the gr-iio [[https:// | + | The source code can be found on the gr-m2k [[https:// |
==== GNURadio-Companion Flowgraph ==== | ==== GNURadio-Companion Flowgraph ==== | ||
- | {{: | + | {{: |
The file {{ : | The file {{ : |