7 read custom blocks 6 it

Info icon This preview shows pages 15–17. Sign up to view the full content.

View Full Document Right Arrow Icon
7. Read [6]. It concisely explains the basics behind creation of custom blocks. 8. Read [7], especially the “Hierarchical Blocks” section. It explains the basics of creating hierarchical blocks in Python. This is important to understand because this is exactly what we have done for the “maxdetect” block; we have essentially created a hierarchical block in Python and added a thread to perform custom processing of the data samples. 9. The comments at the top of maxdetect.xml , as well as the notes in its “ < doc > ” tag, explain a few of the important points about the XML file, such as how to create the thread for our signal processing block. 10. The “ < callback > ” tag in the XML file specifies which function should automatically be exe- cuted when the given parameter changes in the top-level. Take a look at the XML file for the USRP2 source block (in the /opt/gnuradio/grc/blocks/ directory); the USRP2 sink uses this same mechanism to change the center frequency on the hardware if you modify the parameter at run-time (i.e., using a variable slider). 11. The Python code uses an “exponentially-smoothed moving average” to smooth the values of the magnitude before finding the maximum. There are several reasons why we chose to do this: Computationally-inexpensive (only requires a few arithmetic operations) method to apply some smoothing to a system. In fact, several of the GRC blocks use this algorithm, such as the FFT sink. Demonstrates how you might store past history/state of samples in the block, which can be used for processing subsequent samples. In this example, we only store one state variable (the “smooth” variable) for each of the elements in the vector, but you could easily extend this to store a longer history. (This could be useful for implementing blocks such as filters and integrators, although you should ideally leave the heavier signal processing for C++ code.) Demonstrates callbacks on parameters. Try changing the alpha parameter and see how it changes the smoothing behavior of the code in real time! 3.3.2 Making Modifications When making modifications to the Python or XML files, it is important to keep the following things in mind: Every time you change XML file for your custom block, you should exit GRC and start it again. Otherwise, it keeps re-generating the code using its old cached version of the XML file. GRC only reloads the new version of the XML file after restarting. 15
Image of page 15

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
You do NOT need to restart GRC every time you change the Python code for your custom block. This is because it executes your Python script directly at run-time.
Image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern