# grc tutorial3

## Transcript

2 ow graph. You should observe an FFT display similar to the one 5. Save and execute the fl shown below. You may need to click on Autoscale button to scale the data as shown. Note the following: • This data was recorded with a USRP set to 710KHz. Thus, the signal you see at the cent er (indicated as 0 KHz) is actually at 710 KHz. Similarly, the signal at 80 KHz is actually at 710KHz + 80KHz = 790KHz. • The display spans a frequency range from just below - 120KHz to just above 120KHz. This exact span is 256KHz, which corresponds to th e Sample Rate that the data was recorded at. • The peaks that you observe on this display correspond to the carriers for AM broadcast signals. You should also be able to observe the sidebands for the stronger waveforms.

3 6. expand the frequency scale on the FFT display so that you can view the In this step we will signals with greater resolution. Recall from step 5 above that the span of the frequency axis is determined by the sample rate (256K for this file). While we cannot change the origina l data, we can resample it to either increase or decrease the sample rate. We will decrease the sample rate by using decimation. Modify the flow graph as follows: • Add a Variable block (under Variables menu). Set the ID to resamp_factor and the Value to 4 as shown below. • Add the Rational Resampler (NOT Rational Resampler Base) from the Filters menu as shown below. Set its decimation factor to resamp_factor . Thus, it will use the value of the variable set in the previous step (4) to decimate the incoming data. That means that it will divide the incoming data rate by the decimation factor. In this example, the incoming 256K samp/sec data will be converted down to 256K/4 = 64K samp/sec. • Note that the Throttle and FFT Sink now need their Sample Rates changed to correspond to this new rate. Change the Sample Rate in both of these blocks to: samp_rate/resamp_factor . Now we can change the decimation factor i n the Variable block and it will be reflected in each of the other blocks automatically. • Your flow graph should now appear as shown below.

4 7. Execute the new flow graph. You should now observe a frequency span of only 64KHz - actual frequency range does this correspond to? ( 32KHz to +32KHz). What 8. The bandwidth of an AM broadcast signal is 10KHz (+/ - 5KHz from the carrier frequency). You may find it useful to click the “Stop” button on the FFT plot to see this more clearly. Also, note that many stat ions also include additional information outside of the 10KHz bandwidth. This will be discussed later. 9. In order to select the station at 710 KHz (or 0KHz) we need to insert a filter to eliminate all but the one station that we want to receive. This is of ten referred to as a channel filter. Since the station at 710 KHz has been moved to 0 KHz (in the USRP) we will use a low pass filter. The station bandwidth is 10 KHz, so we will use a low pass filter that cuts off at 5 KHz. Insert the Low Pass Filter ( from the Filters menu) between the Rational Resampler and the Throttle. Set the parameters as shown below.

5 10. - 5KHz remains. Execute the flow graph. You should see that only the station between +/ l. In the case of AM, the baseband signal is the 11. The next step is to demodulate the signa envelope or the magnitude of the modulated waveform. GNU Radio contains a Complex to Mag block (in the Type Conversions menu) that can be used for this purpose. Again, the use of complex signal representa tion will be dealt with in depth in the future. Insert this block between the Low Pass Filter and the Throttle. Note that the titles of some of the blocks are now red and the Execute Flow Graph icon is 12. this block, all of the block inputs and dimmed. This indicates an error. Prior to adding outputs were complex values. However, the output of the Complex to Mag block is Float (a real number). Thus, any blocks following this block should be Type: Float. Modify the Throttle and FFT Sink accordingly. 13. E xecute the flow graph. You should now observe the spectrum of the baseband signal in the FFT Sink. Note that since the input data type to the FFT Sink is Float, only the positive frequency spectrum is displayed. The next step is to listen to this demodul ated waveform to confirm that it is in fact receiving 14. the baseband signal. Remove the Throttle and the FFT Blocks. Add an Audio Sink block to the output of the Complex to Mag block. Note that the default sample rate for the Audio Sink is 32KHz. Most cu rrent audio cards require a sample rate of at least 44.1KHz. Change the sample rate to 48 KHz. 15. Note that the sample rate out of the Complex to Mag block is 64K and the input to the Audio Sink is 48K. In order to convert 64K to 48K we need to divide (deci mate) by 4 and multiply (interpolate) by 3. Insert a Rational Resampler between the Complex to Mag and Audio Sink blocks and set the decimation and interpolation as noted above. Also set its Type to Float  Float. 16. Place a Scope Sink at the output of the Rational Resampler (in addition to the Audio Sink). Change its Type to Float. The flow graph should be similar to the one shown below.

6 Execute the flow graph. The Scope Sink should open and display the output waveform. 17. However, you may not yet hear the audio from your speaker. This is due to the fact that the values of the samples going in to the Audio Sink block are too large for the speaker. We need to apply an attenuator to reduce the size of the samples. 18. Insert a Multiply Const block from the Operators category between the Complex to Mag block and the Rational Resampler. Set the IO Type of the block to Float. 19. Add a Variable Slider block. Set the parameters as shown below.

7 20. stant in the Multiply Const block to “volume” so that the slider controls it. The Set the Con final flow graph is shown below. Execute the flow graph. You will probably hear a distorted signal coming out of the speaker. 21. Reduce the slider until the audio is easy t o understand. This will probably be around 3m (.003). You now have a functioning AM receiver. 22. Double click on the Low Pass Filter. Note that it can also decimate. Change the decimation in the filter block to resamp_factor and remove the Rational Resamp ler. The filter now handles both operations. Test the receiver again. 23. Place an FFT sink at the output of the file source, leaving the rest of the flow graph unchanged. Execute the flow graph and observe the location of the other stations in the spectrum . Note that there is a fairly strong signal at 80 KHz (really 710 + 80 = 790 KHz). 24. In order to receive this signal we need to shift it down to zero frequency so that it will pass through the low pass filter. One way to accomplish this is to multiply it by a sinusoid. Modify the flow graph as shown below. Add a Signal Source and set its parameters to output a Cosine at a frequency of - 80000. This negative frequency will shift the entire spectrum to

9 hear and tune up and down the band. Notice you no longer need to adjust the volume. The radio functions the same as a hardware radio.