Note - this page is work-in-progress so expect changes & additions.
We now have some mathematical and practical insight into polar modulation. We also now have some hints regarding it's bandwidth requirements: under certain circumstances both the amplitude and frequency outputs have a high harmonic content. But a practical circuit implementation will impose some bandwidth constraints. For instance, if we use the si5351 for frequency generation, it's output frequency can only be updated at about 12ksps - imposing an upper bandwith on the frequency output of about 6kHz. We therefore want to understand the consequences of these bandwidth restrictions.
My maths skills are insufficient for me to carry out a theoretical analysis, and I'm not even sure whether it's possible. For instance I was surprised to find that even analysis of a nontrivial FM modulation quickly becomes intractible - see here.
I have therefore sought answers by simulating the algorithm. I've written a C program that internally generates test signals, simulates polar modulation and writes the individual samples into an array. It then displays the fourier transform results of this time-sequence of values.
The simulation parameters I've chosen are:
- The simulation should test bandwidths of the amplitude and frequency outputs up to 192ksps.
- The carrier frequency should be at least 5x this frequency, or about 1MHz.
- The simulation sampling should be at least 2x this frequency, but make it 4x for safety: ie. 4MHz.
SAMPLES = 1<<18Fs = 4e6dt = 1.0/Fs
float output[SAMPLES]float outputAmplitudefloat freqDelta
float f1 = 1600 // set the modulation signal valuesfloat a1 = 1.0float f2 = 300float a2 = 1.0int AmpSubsampling = Fs/12000 // for 12kHz amplitude updatesint PhaseSubsampling = Fs/12000 // for 12kHz phase updatesfor t = 0..SAMPLES// calculate the modulating signalt1 = 2*PI*f1*dt*tt2 = 2*PI*f2*dt*tI = a1*cos(t1) + a2*cos(t2)Q = a1*sin(t1) + a2*sin(t2)
if ( t mod AmpSubsampling == 0)
outputAmplitude = sqrt(I*I + Q*Q)
if ( t mod PhaseSubsampling == 0)float phase = atan2(Q, I);float dp = phase - prev_phase;prev_phase = phase;if(dp < 0) dp += 2*PI; // phase unwrapif(dp >= PI) dp -= 2*PI; // reverse phase unwrapfreqDelta = dp * Fs/PhaseSubsampling /(2.0*PI)carrierPhase += 2.0*PI*(fc+freqDelta)*dtoutput[t] = outputAmplitude * cos(carrierPhase)
ApplyWindowingFunction(output)FFTresult[] = FFT_Transform(output)
power[] = convertResultToPowerIndB(FFTresult)
DisplayAsChart(power)
For the Fourier Transform calculation I use this library - it's open-source, quite fast, the code is easily read, and I was already familiar with it, having used it on other projects. Other libraries might be faster, but raw speed is not critical here.
To simulate various conditions, such as amplitude and phase errors that might be introduced by the Hilbert transform, this core simulation code is supplemented with additional calculations.
When I first wrote this code, I spent some time experimenting with it to give myself confidence that it was both doing what was expected, and that I was able to correctly interprete the results. Some experiments were:
- Temporarily replaced the modulated carrier with pure sinusoid and verified that the result appeared in the predicted FFT "bin".
- Temporarily generated two carriers close together and verified that two peaks were present in the FFT result and at the predicted location.
- Temporarily AM modulated the carrier with a low-frequency sinusoid and confirmed the FFT result was a carrier with two side lobes.
- Reduced and increased the amplitude of the carrier by a factor of 10 and confirmed that the power output changed by 20dB.
Results with 192kHz Sample Rate
The horizontal lines are 10dB apart, and the total span is about 12kHz. This is good evidence that the algorithm is working as expected.
Results with 12kHz Sample Rate - slight amplitude delay
At a difference frequency of 1000Hz, the spurious signals have continued to grow but the nearby peaks remain about 40dB down:
A similar pattern emerges with different sample rates - with a higher sample rate and the same difference-frequency the power of the spuri are lower (and vice versa).
Results with 12kHz Frequency Sample Rate, Increased Amplitude Sample Rate
Sensitivity to Amplitude Variation
To Follow (maybe):
- Source of errors arising from lower sampling rate
- Alternative phase unwrapping code?
- Hardware configuration and results of tests on the hardware
- Indications of the algorithm's sensitivity to
- Hilbert transform phase & amplitude errors
- Delays between the amplitude & frequency outputs
No comments:
Post a Comment