Forum Discussion
Division Approximation In Fm Demodulator
i am a post-graduate student at the university of ioannina greece "physics department". my thesis subject has to do about an implement of sdr receiver and demodulation of fm signal. i already have implement the ddc part in an fpga with my i and q signals in two complement's integer format (the same format used by the adc) but i have problem with the demodulation and especially with division.i use a digital phase discriminator algorithm witch produce an output following the next equation (i*dq – qdi)/(i^2 + q^2).i can compute the numerator and the denominator but the problem is with division. i can use a divisor but the result from this division is just a quotient and a remainder, this wont give the desired output in a fixed scale capable to be processed properly by a dac.is there any possible way to implement a divisor with a fixed range quotient in regard with the remainder.in other words is it possible to produce an approximated quotient from the division of two complement format signals. with only the knowledge of the first quotient and the remainder, and if that is possible what is the form of the output?any answer guidance proposed bibliography or links will be very helpful. (http://www.fpga4fun.com/forum/viewtopic.php?t=1669&start=0&postdays=0&postorder=asc&highlight=)
23 Replies
- Altera_Forum
Honored Contributor
Actually if we clip in someway the variations of amplitude noise in our incoming signal so it has a constant amplitude then its for sure true that the algorithm I*dQ-Q*dI will work right.....if anyone has an idea on how can we achieve this before or after the ADC.....
- Altera_Forum
Honored Contributor
Actually the Cordic Atan function isn't that complicated. It's just add/subtract and a few precalculated constants. After just 8 iterations, you're within 1° but even more important, you don't need to divide Q/I or normalize the amplitude. Feed the raw I and Q samples into the algorithm and get phase out the other side.
Then just do the dO/dt to convert to FM. Given I and Q, to calculate phase in degrees, first we need to account for the quadrant the signal is in. I[0] = (I<0) ? ( (Q<0) ? -Q : Q) : I; Q[0] = (I<0) ? ( (Q<0) ? I : -I) : Q; Phase[0] = (I<0) ? ( (Q<0) ? -90 : 90) : 0 Now iterate the following three lines till you're happy with the resolution for (n=1; n<sufficient_iterations; n++) { I[n] = I[n-1] + Sign(Q[n-1]) * Q[n-1]/(2^(n-2) ); // Sign(n) = ±1, Div by 2^n is a shift right. Q[n] = Q[n-1] - Sign(Q[n-1]) * I[n-1]/(2^(n-2) ); Phase[n] = Phase[n-1] + Sign(Q[n-1]) * Atan(1/(2^(n-2)))*180/pi; // The Atan is usually a constant in a look up table. } Note, I translated this from a mathCad routine I have, so the C code might be off a bit. This will get you back to my original post which, by the way, is the basis for the radio I designed in 1990 that Nasa has been using since then to retrieve the instrumentation data from the space shuttles. - Altera_Forum
Honored Contributor
Hi Xristos,
That is the claim and depends on how much other spaghetti is there in the chip. The best way is to try and design your multipliers(12 bit wide) and compile then quartus will tell you the fmax value achieved. - Altera_Forum
Honored Contributor
thanks Kaz!!!
I agree with you cordic is not such a good idea!!!Another question... In cyclone II data sheet they that the embedded multipliers can achieve performance up to 250 Mhz. That means that i can multiply for example samples from an ADC up to 250 Msamples/s with each sample to be 12 bit in width without any problem? http://www.alteraforum.com/proweb/misc/progress.gif (http://www.alteraforum.com/forum/editpost.php?do=editpost&p=19329) - Altera_Forum
Honored Contributor
Hi Xristos,
the atan method leads to the same phenomenon of small swing just over zero. So I don't see any gain using that method. Moreover the cordic method is more difficult to implement compared to other methods. Attached a fully functioning Matlab code that uses 3 methods and compares the swing of signal. - Altera_Forum
Honored Contributor
Hi kaz!
I believe too and i wish that recovered I and Q are positive numbers!!!Another option that sounds interesting is to build a cordic algorithm so i can compute the P[n]=atan(Q[n]/I[n]) and then take the message by derivation m[n]=P[n]-P[n-1]!!! - Altera_Forum
Honored Contributor
Hi Xristos,
I am aware that you are doing 2's complement. But since the Matlab model shows positive values only then I think you can safely consider all values to be so (unless proved otherwise). You may therefore either assume all 16 bits as magnitude bits(even though they are meant to cover negative values. Then you will need to offset values down if you want + representation. If in doubt you may as well use 15 bits and move the '1' to bit (30) rather than bit(31) for the num. For the denum move the bit to bit(16). In this case you will cover 15 bits only(even after any offset). For offset you can subtract each value by a the mean(you don't need to compute the mean in real time but you can precompute it) - Altera_Forum
Honored Contributor
Thanks kaz!!!But my I and Q singals have two complement form.Am i able to follow the procedure you mention above, or i have to change them into an other form.Something else by the term Msb you mean the last 16 bits of the number?So i scale the first one of the last 16 bits of the numerator until it goes from it's place to bit 31?All the arithmitic in my system is in two complement form...The singal being digitized by a an adc and has a two complement form.Then i multiply it with a sin and a cosine which have also two complement form.The coefficient of Fir filter are also in two complement form so I and Q have two complement form.In all these multiplications i truncate the result to Msb.
....by the way in similar discussion in another forum someone claim that i don't need the last division by I^2+Q^2 because as they said i measure angles not amplitude. In fact, in a typical analog FM receiver, amplitude noise can mess up reception of the signal so they clip the amplitude to remove the noise. - Altera_Forum
Honored Contributor
I was referring to the above discussion about omitting the division, if the signal magnitude is constant. Generally it isn't constant. Automatic scaling still leaves an 1:2 amplitude variation. So if you require the demodulated signal to be scaled correctly, you either should use the division or somethink like ADC. I don't want to suggest a particular implementation, cause a suitable design depends on the overall system structure.
- Altera_Forum
Honored Contributor
--- Quote Start --- Thanks for the replays.You are probably right..FvM do you have any idea on how i can implement the AGC you mentioned.there is a same idea its called Automatic scaling function in a work according to this link http://rfdesign.com/mag/604rfdf4.pdf if you have time take a look! --- Quote End --- Hi Xristos, I actually indicated in an above post a bit about automatic scaling mentioned in your document. It multiplies the num by 2^n and the denum by 2^-m without defining n,m. First you don't need AGC as this is meant for amplitude scaling against a variable input signal. In your case we are looking for phase measurement. All you need is scale and get the division right.(imagine the input signal as just different frequencies with same amplitude, though some advice clipping this swing) I believe yur document people mean the following for n,m of automatic scaling: (remember all values are positive) look for the location of MSB that equals '1' in the 32 bit wide num and denum. then shift num value until you get this '1' in bit(31). Similarly shift the denum towrds LSB until this '1' is at bit(16). Now divide and ignore the remainder. You should get a signal that swings across 16 bits. Personally I don't see any relevance of using the denum. After all we are forcing it to 1 on the 16 bits though its fraction is left over on the other 16 bits infront, either way it works(ignoring denum or not).