-
Notifications
You must be signed in to change notification settings - Fork 0
Lab 2
##Exercise 1 - AM Modulator
In this part of the lab we created an AM modulator. Recall the equation for AM:
We expanded this so it was simpler to implement. We also calculated the modulation index and set an indicator for it. The implementation is given below, which involved just a few multipliers and dividers and an adder:
###Screenshot 1 - Diagram for ex1.
###Screenshot 2 - Panel for ex1.
We can clearly see the higher frequency of the carrier wave, and how modulating the signal affects the frequency domain. The PSD has one major peak at 10000Hz (the carrier frequency) and two smaller peaks 1000Hz (the message frequency) either side of the major peak. The AM signal is shown.
We also learnt how to create sub VIs, which allows you to import the module into any future VIs. The icon we made is shown below. We added the inputs on the left and outputs on the right and also added a nice image in the centre which clearly explains the functionality of the module. We were able to select the icon and increase the size so we could fit more inputs/outputs on either side.
###Screenshot 3 - Sub VI icon for amplitude modulation.
Next we wanted to observe what happens when you change the modulation index, which is given by the following equation:
μ = Am / Ac
We set Ac to 2, and then set Am to 1, 2 and 3 to get a corresponding modulation index of 0.5, 1 and 1.5 respectively. The spectra are shown below:
###Screenshot 4 - Modulation index of 0.5; Am = 1.
###Screenshot 5 - Modulation index of 1; Am = 2.
###Screenshot 6 - Modulation index of 1.5; Am = 3.
After reviewing the resulting graphs we can see that increasing the modulation index does not affect the location of the peaks in the PSD, but the amplitude of the sideband peaks is increasing. This makes sense since we are increasing the amplitude of the message signal and therefore increasing the energy of the sidebands.
We can also see some strange effects happening the the signal in time domain. Initially it seems we are decreasing the envelope the higher the modulation index, but then with a modulation index of 1.5 it seems to increase again. Upon further research we can really understand what is happening, as it is hard to see from our diagram. The modulation index needs to stay between 0 and 1, and if it goes beyond 1 the signal becomes over-modulated and the signal is distorted. It then becomes impossible to use an envelope detector to demodulate the signal. You can however still use coherent detection. We can see this effect clearly in the diagram below:
###Screenshot 7 - Diagram showing the effects of increasing modulation index (Diagram from Wikipedia).
Next we wanted to observe the effect of changing the message frequency, whilst keeping the modulation index at 1 with both Am and Ac set to 1. We changed the message signal frequency to 1k, 2k and 5k and the corresponding plots are shown below:
###Screenshot 8 - Panel view with the message frequency set to 1k.
###Screenshot 9 - Panel view with the message frequency set to 2k.
###Screenshot 10 - Panel view with the message frequency set to 5k.
Here we observe that the sideband peaks on the PSD are getting further away from the main peak at 10kHz the more we increase the frequency. The amplitude of the peaks is not changing because we are not changing the message or carrier amplitudes.
We see a more interesting affect in the time domain representations. As we increase the frequency we are getting closer and closer to the carrier frequency and we see some aliasing occur. At this point we cannot accurately reconstruct the original message wave.
##Exercise 2 - AM Demodulators
In this lab we are creating AM demodulators using two techniques, Coherent Demodulation and Envelope Detection.
###Exercise 2a - Coherent Detection
This demodulation technique uses a cosine wave of the same frequency of the carrier. By multiplying by the carrier, we move the frequency spectrum back to the origin and also moves the same spectrum to a higher frequency. We then use a LPF to remove the higher frequency components and finally remove the DC offset to get left with the message signal.
###Screenshot 11 - The diagram view of the coherent demodulator.
###Screenshot 12 - The panel view of the coherent demodulator.
Here we can see a peak in the PSD at 1000Hz, which was our original message signal frequency. We set a cutoff frequency of ~3000, so that is above the 1000Hz we want, but still below the higher frequency component at 20000Hz.
Mathematical Proof:
The following is proof that the demodulation scheme works.
If we recall the double angle cosine formula:
cos^2(x) = 1/2 + 1/2cos(2x)
We then use a low pass filter to remove the 4πfc frequency components.
And remove the DC component as this gets rid of the Ac/2 term, leaving us with just the message signal (although it is scaled).
In order to get the correct amplitude of the message signal we must either double the message signal amplitude before modulating, or when demodulating multiply by 2cos(2πfct).
###Exercise 2b - Envelope Detection
This demodulation technique relies on the envelope of the received signal, meaning that it does not work in all cases.
###Screenshot 13 - The diagram view of the envelope detector.
The diagram works by converting the waveform values to an array so we can do some comparisons on each value. We then use a for loop which iterates through each of the values in the array and checks if it is greater than 0. If it is, then we output the array value, otherwise we output 0. This ensures we eliminate all the negative parts of the wave. This is then built back into a waveform using the same parameters from the earlier array function. Finally we use a LPF to remove the high frequency component leaving us with the message signal in the form of an envelope. We then take away the DC offset to get the message signal. Below we see the expected peak at 1000Hz:
###Screenshot 14 - The panel view of the envelope detector.
Envelope detection works by using a diode to keep the positive part of the wave, and then passing the signal through a low pass filter to remove the high frequency carrier component.
The capacitor is continually charged and discharged so that the output is the envelope of the signal. Values of the components must be chosen so that the capacitor does not discharge too slowly or too quickly. The input is usually scaled first by π because the LPF will reduce the amplitude of the signal.
After this point we have an envelope representing the message signal, but we must remove the DC offset to get the original message signal.
##Exercise 3 - AM Simulation
In this exercise we used the VIs created earlier for AM modulation and demodulation and made a top level so we could observe the whole AM process. We used a while loop so that we could observe the effects of changing the parameters without having the stop and restart the process. The diagram is shown below:
###Screenshot 15 - The diagram view for exercise 3.
We then changed the amplitude of the message signal from 1 - 4 in steps of 1 and witnessed the effect on both modulation techniques. First is with a message amplitude of 1:
###Screenshot 16 - The panel view with message amplitude set to 1.
Here we see the major peak and sidebands in the AM signal, and the corresponding demodulation PSDs. Here we notice no difference between the techniques. Next we tried an amplitude of 2:
###Screenshot 17 - The panel view with message amplitude set to 2.
Here we can see the envelope of the signal is much smaller, and the sidebands on the PSD have a higher amplitude because they are carrying more energy. Both techniques are still able to demodulate effectively producing identical outputs. Notice the PSD of the demodulated signal has a higher amplitude which is because the original message signal has a higher amplitude. Next we tried an amplitude of 3:
Here we start to see the envelope detection technique break down. This is because we now have a modulation index of 1.5, and you can see in the AM time domain graph that there is no clear envelope. This causes over modulation and the signal is distorted. As we can see the envelope detection does no longer produce just the message frequency, but also some minor higher frequencies. Next we tried an amplitude of 4:
Here we see the effect of over modulation even more. We now have a modulation index of 2, which is causing the minor peaks in the demodulated signal to have higher amplitude, meaning they are more present in the signal. The demodulated signal is even further away from being like the original message signal. Again we can see that coherent detection has no problem dealing with this change.
From this we can conclude that Envelope Detection will only work when the modulation index is between 0 and 1. If the modulation index increases beyond this then the message signal cannot be reconstructed accurately. Coherent Detection on the other hand will always work, no matter the modulation index.
##Exercise 4 - AM Communications Via USRP
In this exercise we use the USRP device to actually transmit an AM signal. The USRP modules do all the modulation and demodulation for us, so all we need to do is provide it with complex data. Below is the diagram for the Tx module:
###Screenshot 18 - The diagram for the USRP Tx module.
The two modules on the far left open up a USRP Tx session and set the relevant parameters for transmitting. All the main processing is done in a while loop which can be stopped by us on the panel or automatically stopped when the USRP encounters an error. Initially we didn't realise this was the case and became confused when our program stopped execution randomly. Upon further inspection we noticed it was because of these errors which if you read, may help you to stop this happening again (e.g. reducing IQ rate or increasing number of samples). In the while loop we first add one to the signal so that it is all positive. Then we convert it into an array so we can do calculations on the data. The array is normalised by dividing by the highest value and then finally converted to complex by combining this data with a constant of 0. The two modules on the right transmit the data and close the USRP session respectively. Below is a diagram of the receiver:
###Screenshot 19 - The diagram for the USRP Rx module.
The surrounding modules in this diagram work the same way as in the Tx module. They open the session, set parameters and close the session when needed. Again the main processing is done in a while loop. The module on the left of the while loop takes one block of message samples at a time and allows it to be processed. First we convert this waveform to an array, and then convert the complex array into real and imaginary. We can discard the imaginary part, since the receiver just set this to 0. We then remove the DC offset that was added before transmitting and pass this through a LPF to remove the high frequency carrier. This array data is then converted back into a waveform and displayed in the time and frequency domain.
The corresponding Tx and Rx panels are shown below. Notice we manage to demodulate the message signal perfectly with no other frequencies present.
###Screenshot 20 - The panel view for the Tx module.
###Screenshot 21 - The panel view for the Rx module.
Next we tried to transmit a 5kHz message signal with modulation index 1. We had to change the low cut off frequency so that it did not cut off the 5kHz signal.
###Screenshot 22 - The panel view for transmitting a 5kHz message signal.
Here we notice the signal is picked up perfectly, with little noise. Next we wanted to observe the effect of noise on the signal. To do this we increased the receivers gain to 20dB so that some of the weaker signals would be amplified enough to be seen. We then changed the modulation index and saw how this affects a signal. We started with a modulation index of 1, shown below:
###Screenshot 23 - The panel view for a modulation index of 1.
Here we can see an almost perfect demodulated signal. Next we reduced the modulation index to 0.4:
###Screenshot 24 - The panel view for a modulation index of 0.4.
Here we can start to see noise affecting the signal. We predominantly pick up the 5kHz signal, but there are also some other minor peaks at other frequencies. If we reduce the modulation index even further, to 0.1, the effect becomes even more drastic:
###Screenshot 25 - The panel view for a modulation index of 0.1.
At this point the 5kHz signal peak is now very small compared to the other frequencies we are picking up as noise.