DSPRelated.com
Forums

Downconversion of Signals to BaseBand

Started by engrmasood2002 June 26, 2014
Hi All
An SDR Software  (SDRSharp) plays the file containing two stations one at
0hz and other at 8khz. By Clicking at both the stations one by one (FFT
Display) stations can be heard.
I tried to demodulate them in my software and always able to hear station
at 0Hz after demodulation. even i have shifted 8Khz signal to 0Hz but i am
able to hear only station that was initially at 0Hz. Maybe i am doing
something wrong. can any one tell me by looking at the code what i am doing
wrong

float carrFrq=8000.0;    //station to tune and to be shifted to 0Hz
float	LO_Frq=carrFrq;
float	LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS);
float	LO_ph_acc=0;

 float       LO_ph_acc=0;  // NCO
	for(int a=0;  a<samples_count*2;a+=2)
		{	
				i = fptr[a];             // fptr contains I/Q from wave file at 0Hz
		               q = fptr[a+1];

				////tunning test///////////////////////
				LO_ph_acc+=LO_Ph_Inc;

				if(LO_ph_acc> (2 * PI) )
					LO_ph_acc-=(2 * PI);

				i*=cos(LO_ph_acc); //		shift I/Q from 8 khz to 0 Hz
				q*=sin(LO_ph_acc); //		
				
	final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate				
		}	 

_____________________________		
Posted through www.DSPRelated.com
On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote:

> Hi All An SDR Software (SDRSharp) plays the file containing two > stations one at 0hz and other at 8khz. By Clicking at both the stations > one by one (FFT Display) stations can be heard. > I tried to demodulate them in my software and always able to hear > station at 0Hz after demodulation. even i have shifted 8Khz signal to > 0Hz but i am able to hear only station that was initially at 0Hz. Maybe > i am doing something wrong. can any one tell me by looking at the code > what i am doing wrong > > float carrFrq=8000.0; //station to tune and to be shifted to 0Hz > float LO_Frq=carrFrq; > float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); > float LO_ph_acc=0; > > float LO_ph_acc=0; // NCO > for(int a=0; a<samples_count*2;a+=2) > { > i = fptr[a]; // fptr contains
I/Q from wave file at 0Hz
> q = fptr[a+1]; > > ////tunning test/////////////////////// > LO_ph_acc+=LO_Ph_Inc; > > if(LO_ph_acc> (2 * PI) ) > LO_ph_acc-=(2 * PI); > > i*=cos(LO_ph_acc); // shift I/Q
from 8 khz to 0 Hz
> q*=sin(LO_ph_acc); // > > final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate > } > > _____________________________ > Posted through www.DSPRelated.com
You are not doing a full complex downconversion. The nomenclature gets confusing, but for j = sqrt(-1), your received value is a complex number equal to x = i + j*q (note that my 'j' is not your index variable in the code above). You want to multiply it by e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) Do the math, and you should (if I have my head on straight) get: fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); Note that the C++ standard library has (if I remember correctly) a complex data type that'll take care of the arithmetic for you, possibly in a more efficient manner than you can hand-code it. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
>On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote: > >> Hi All An SDR Software (SDRSharp) plays the file containing two >> stations one at 0hz and other at 8khz. By Clicking at both the stations >> one by one (FFT Display) stations can be heard. >> I tried to demodulate them in my software and always able to hear >> station at 0Hz after demodulation. even i have shifted 8Khz signal to >> 0Hz but i am able to hear only station that was initially at 0Hz. Maybe >> i am doing something wrong. can any one tell me by looking at the code >> what i am doing wrong >> >> float carrFrq=8000.0; //station to tune and to be shifted to 0Hz >> float LO_Frq=carrFrq; >> float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); >> float LO_ph_acc=0; >> >> float LO_ph_acc=0; // NCO >> for(int a=0; a<samples_count*2;a+=2) >> { >> i = fptr[a]; // fptr contains >I/Q from wave file at 0Hz >> q = fptr[a+1]; >> >> ////tunning test/////////////////////// >> LO_ph_acc+=LO_Ph_Inc; >> >> if(LO_ph_acc> (2 * PI) ) >> LO_ph_acc-=(2 * PI); >> >> i*=cos(LO_ph_acc); // shift I/Q >from 8 khz to 0 Hz >> q*=sin(LO_ph_acc); // >> >> final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate >> } >> >> _____________________________ >> Posted through www.DSPRelated.com > >You are not doing a full complex downconversion. The nomenclature gets >confusing, but for j = sqrt(-1), your received value is a complex number >equal to > >x = i + j*q > >(note that my 'j' is not your index variable in the code above). You >want to multiply it by > >e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) > >Do the math, and you should (if I have my head on straight) get: > >fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); >fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); > >final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); > >Note that the C++ standard library has (if I remember correctly) a >complex data type that'll take care of the arithmetic for you, possibly >in a more efficient manner than you can hand-code it. > >-- > >Tim Wescott >Wescott Design Services >http://www.wescottdesign.com > >
Tim Thanks for answering my newbie type questions. I am moving in dsp by the help of people like you and trying to implement each block after understanding the concept and then seeing the result programmatically. I am now stuck in Digital Down conversion and even after googling unable to find: 1. Difference between half and full complex down conversion. 2. Which (complex down conversion) is suitable for Frequency translation or tuning given we have I/Q samples. 3.Which (complex down conversion) is suitable for Frequency translation or tuning given we have raw samples and we have to generate base band ((I/Q) for given frequency. 4. Any article with example psuedocode that can be translated in to software (source code). The code for down-conversion i adopted was from saqrx sdr files, if its not correct then i doubt how it works because it uses LO for 16500 hz for signals of interest and multiply signals from sound card ADC to this LO to generate I/Q samples. Thanks _____________________________ Posted through www.DSPRelated.com
>>On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote: >> >>> Hi All An SDR Software (SDRSharp) plays the file containing two >>> stations one at 0hz and other at 8khz. By Clicking at both the
stations
>>> one by one (FFT Display) stations can be heard. >>> I tried to demodulate them in my software and always able to hear >>> station at 0Hz after demodulation. even i have shifted 8Khz signal to >>> 0Hz but i am able to hear only station that was initially at 0Hz.
Maybe
>>> i am doing something wrong. can any one tell me by looking at the code >>> what i am doing wrong >>> >>> float carrFrq=8000.0; //station to tune and to be shifted to 0Hz >>> float LO_Frq=carrFrq; >>> float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); >>> float LO_ph_acc=0; >>> >>> float LO_ph_acc=0; // NCO >>> for(int a=0; a<samples_count*2;a+=2) >>> { >>> i = fptr[a]; // fptr contains >>I/Q from wave file at 0Hz >>> q = fptr[a+1]; >>> >>> ////tunning test/////////////////////// >>> LO_ph_acc+=LO_Ph_Inc; >>> >>> if(LO_ph_acc> (2 * PI) ) >>> LO_ph_acc-=(2 * PI); >>> >>> i*=cos(LO_ph_acc); // shift I/Q >>from 8 khz to 0 Hz >>> q*=sin(LO_ph_acc); // >>> >>> final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate >>> } >>> >>> _____________________________ >>> Posted through www.DSPRelated.com >> >>You are not doing a full complex downconversion. The nomenclature gets >>confusing, but for j = sqrt(-1), your received value is a complex number
>>equal to >> >>x = i + j*q >> >>(note that my 'j' is not your index variable in the code above). You >>want to multiply it by >> >>e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) >> >>Do the math, and you should (if I have my head on straight) get: >> >>fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); >>fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); >> >>final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); >> >>Note that the C++ standard library has (if I remember correctly) a >>complex data type that'll take care of the arithmetic for you, possibly >>in a more efficient manner than you can hand-code it. >> >>-- >> >>Tim Wescott >>Wescott Design Services >>http://www.wescottdesign.com >> >> > > Tim >Thanks for answering my newbie type questions. I am moving in dsp by the >help of people like you and trying to implement each block after >understanding the concept and then seeing the result programmatically. >I am now stuck in Digital Down conversion and even after googling unable
to
>find: > >1. Difference between half and full complex down conversion. > >2. Which (complex down conversion) is suitable for Frequency translation
or
>tuning given we have I/Q samples. > >3.Which (complex down conversion) is suitable for Frequency translation
or
>tuning given we have raw samples and we have to generate base band ((I/Q) >for given frequency. > >4. Any article with example psuedocode that can be translated in to >software (source code). > >The code for down-conversion i adopted was from saqrx sdr files, if its
not
>correct then i doubt how it works because it uses LO for 16500 hz for >signals of interest and multiply signals from sound card ADC to this LO
to
>generate I/Q samples. > >Thanks > > > >_____________________________ >Posted through www.DSPRelated.com >
I just found a good article at http://www.cs.tut.fi/kurssit/TLT-9707/presentations/Complex-Signals-and-Radios-short-2pp.pdf and example for down coversion described in the down-conversion figure for Complex signals lead me to these equations for frequency translation but still no luck. LO_ph_acc+=LO_Ph_Inc; if(LO_ph_acc> (2 * PI) ) LO_ph_acc-=(2 * PI); i=(i * cos(LO_ph_acc)) - (q* sin(LO_ph_acc)); q=(i* sin(LO_ph_acc)) + (q* cos(LO_ph_acc)); _____________________________ Posted through www.DSPRelated.com
"engrmasood2002" <100558@dsprelated> writes:

>>On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote: >> >>> Hi All An SDR Software (SDRSharp) plays the file containing two >>> stations one at 0hz and other at 8khz. By Clicking at both the stations >>> one by one (FFT Display) stations can be heard. >>> I tried to demodulate them in my software and always able to hear >>> station at 0Hz after demodulation. even i have shifted 8Khz signal to >>> 0Hz but i am able to hear only station that was initially at 0Hz. Maybe >>> i am doing something wrong. can any one tell me by looking at the code >>> what i am doing wrong >>> >>> float carrFrq=8000.0; //station to tune and to be shifted to 0Hz >>> float LO_Frq=carrFrq; >>> float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); >>> float LO_ph_acc=0; >>> >>> float LO_ph_acc=0; // NCO >>> for(int a=0; a<samples_count*2;a+=2) >>> { >>> i = fptr[a]; // fptr contains >>I/Q from wave file at 0Hz >>> q = fptr[a+1]; >>> >>> ////tunning test/////////////////////// >>> LO_ph_acc+=LO_Ph_Inc; >>> >>> if(LO_ph_acc> (2 * PI) ) >>> LO_ph_acc-=(2 * PI); >>> >>> i*=cos(LO_ph_acc); // shift I/Q >>from 8 khz to 0 Hz >>> q*=sin(LO_ph_acc); // >>> >>> final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate >>> } >>> >>> _____________________________ >>> Posted through www.DSPRelated.com >> >>You are not doing a full complex downconversion. The nomenclature gets >>confusing, but for j = sqrt(-1), your received value is a complex number >>equal to >> >>x = i + j*q >> >>(note that my 'j' is not your index variable in the code above). You >>want to multiply it by >> >>e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) >> >>Do the math, and you should (if I have my head on straight) get: >> >>fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); >>fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); >> >>final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); >> >>Note that the C++ standard library has (if I remember correctly) a >>complex data type that'll take care of the arithmetic for you, possibly >>in a more efficient manner than you can hand-code it. >> >>-- >> >>Tim Wescott >>Wescott Design Services >>http://www.wescottdesign.com >> >> > > Tim > Thanks for answering my newbie type questions. I am moving in dsp by the > help of people like you and trying to implement each block after > understanding the concept and then seeing the result programmatically. > I am now stuck in Digital Down conversion and even after googling unable to > find: > > 1. Difference between half and full complex down conversion. > > 2. Which (complex down conversion) is suitable for Frequency translation or > tuning given we have I/Q samples. > > 3.Which (complex down conversion) is suitable for Frequency translation or > tuning given we have raw samples and we have to generate base band ((I/Q) > for given frequency. > > 4. Any article with example psuedocode that can be translated in to > software (source code). > > The code for down-conversion i adopted was from saqrx sdr files, if its not > correct then i doubt how it works because it uses LO for 16500 hz for > signals of interest and multiply signals from sound card ADC to this LO to > generate I/Q samples. > > Thanks
Hello, It appears to me that you are putting the hart before the corse. What I suggest is that you shut down your computer, get out a book (Rick Lyons' "Understanding Digital Signal Processing" would be good), a pencil, and some paper, and read about complex upconversion and downconversion. Write out some simple examples by hand. Then I bet a few lights will come on. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Randy Yates <yates@digitalsignallabs.com> writes:
> [...] >> Tim >> Thanks for answering my newbie type questions. I am moving in dsp by the >> help of people like you and trying to implement each block after >> understanding the concept and then seeing the result programmatically. >> I am now stuck in Digital Down conversion and even after googling unable to >> find: >> >> 1. Difference between half and full complex down conversion. >> >> 2. Which (complex down conversion) is suitable for Frequency translation or >> tuning given we have I/Q samples. >> >> 3.Which (complex down conversion) is suitable for Frequency translation or >> tuning given we have raw samples and we have to generate base band ((I/Q) >> for given frequency. >> >> 4. Any article with example psuedocode that can be translated in to >> software (source code). >> >> The code for down-conversion i adopted was from saqrx sdr files, if its not >> correct then i doubt how it works because it uses LO for 16500 hz for >> signals of interest and multiply signals from sound card ADC to this LO to >> generate I/Q samples. >> >> Thanks > > Hello, > > It appears to me that you are putting the hart before the corse. > > What I suggest is that you shut down your computer, get out a book (Rick > Lyons' "Understanding Digital Signal Processing" would be good), a > pencil, and some paper, and read about complex upconversion and > downconversion. Write out some simple examples by hand. Then I bet a few > lights will come on.
PS: It has been said that "a computer is an amplifier for the mind," so you have to feed it some signal to begin with. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
On Fri, 27 Jun 2014 02:32:33 -0500, engrmasood2002 wrote:

>>>On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote: >>> >>>> Hi All An SDR Software (SDRSharp) plays the file containing two >>>> stations one at 0hz and other at 8khz. By Clicking at both the > stations >>>> one by one (FFT Display) stations can be heard. >>>> I tried to demodulate them in my software and always able to hear >>>> station at 0Hz after demodulation. even i have shifted 8Khz signal to >>>> 0Hz but i am able to hear only station that was initially at 0Hz. > Maybe >>>> i am doing something wrong. can any one tell me by looking at the >>>> code what i am doing wrong >>>> >>>> float carrFrq=8000.0; //station to tune and to be shifted to 0Hz >>>> float LO_Frq=carrFrq; >>>> float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); >>>> float LO_ph_acc=0; >>>> >>>> float LO_ph_acc=0; // NCO >>>> for(int a=0; a<samples_count*2;a+=2) >>>> { >>>> i = fptr[a]; // fptr contains >>>I/Q from wave file at 0Hz >>>> q = fptr[a+1]; >>>> >>>> ////tunning test///////////////////////
LO_ph_acc+=LO_Ph_Inc;
>>>> >>>> if(LO_ph_acc> (2 * PI) ) >>>> LO_ph_acc-=(2 * PI); >>>> >>>> i*=cos(LO_ph_acc); // shift I/Q >>>from 8 khz to 0 Hz >>>> q*=sin(LO_ph_acc); // >>>> >>>> final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate >>>> } >>>> >>>> _____________________________ >>>> Posted through www.DSPRelated.com >>> >>>You are not doing a full complex downconversion. The nomenclature gets >>>confusing, but for j = sqrt(-1), your received value is a complex >>>number > >>>equal to >>> >>>x = i + j*q >>> >>>(note that my 'j' is not your index variable in the code above). You >>>want to multiply it by >>> >>>e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) >>> >>>Do the math, and you should (if I have my head on straight) get: >>> >>>fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); >>>fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); >>> >>>final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); >>> >>>Note that the C++ standard library has (if I remember correctly) a >>>complex data type that'll take care of the arithmetic for you, possibly >>>in a more efficient manner than you can hand-code it. >>> >>>-- >>> >>>Tim Wescott Wescott Design Services http://www.wescottdesign.com >>> >>> >>> >> Tim >>Thanks for answering my newbie type questions. I am moving in dsp by the >>help of people like you and trying to implement each block after >>understanding the concept and then seeing the result programmatically. >>I am now stuck in Digital Down conversion and even after googling unable > to >>find: >> >>1. Difference between half and full complex down conversion. >> >>2. Which (complex down conversion) is suitable for Frequency translation > or >>tuning given we have I/Q samples. >> >>3.Which (complex down conversion) is suitable for Frequency translation > or >>tuning given we have raw samples and we have to generate base band >>((I/Q) >>for given frequency. >> >>4. Any article with example psuedocode that can be translated in to >>software (source code). >> >>The code for down-conversion i adopted was from saqrx sdr files, if its > not >>correct then i doubt how it works because it uses LO for 16500 hz for >>signals of interest and multiply signals from sound card ADC to this LO > to >>generate I/Q samples. >> >>Thanks >> >> >> >>_____________________________ >>Posted through www.DSPRelated.com >> >> > I just found a good article at > http://www.cs.tut.fi/kurssit/TLT-9707/presentations/Complex-Signals-and-
Radios-short-2pp.pdf
> > and example for down coversion described in the down-conversion figure > for Complex signals lead me to these equations for frequency translation > but still no luck. > > LO_ph_acc+=LO_Ph_Inc; > > if(LO_ph_acc> (2 * PI) ) > LO_ph_acc-=(2 * PI); > > i=(i * cos(LO_ph_acc)) - (q* sin
(LO_ph_acc));
> q=(i* sin(LO_ph_acc)) + (q* cos
(LO_ph_acc)); You modify i, then use the modified i to calculate q. That's why I changed the variable names in my example. That's also why -- if you're working in C++, it's nice to use a complex library that takes care of those nits for you with pre-tested code. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
On Fri, 27 Jun 2014 09:29:45 -0400, Randy Yates wrote:

> "engrmasood2002" <100558@dsprelated> writes: > >>>On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote: >>> >>>> Hi All An SDR Software (SDRSharp) plays the file containing two >>>> stations one at 0hz and other at 8khz. By Clicking at both the >>>> stations one by one (FFT Display) stations can be heard. >>>> I tried to demodulate them in my software and always able to hear >>>> station at 0Hz after demodulation. even i have shifted 8Khz signal to >>>> 0Hz but i am able to hear only station that was initially at 0Hz. >>>> Maybe i am doing something wrong. can any one tell me by looking at >>>> the code what i am doing wrong >>>> >>>> float carrFrq=8000.0; //station to tune and to be shifted to 0Hz >>>> float LO_Frq=carrFrq; >>>> float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); >>>> float LO_ph_acc=0; >>>> >>>> float LO_ph_acc=0; // NCO >>>> for(int a=0; a<samples_count*2;a+=2) >>>> { >>>> i = fptr[a]; // fptr contains >>>I/Q from wave file at 0Hz >>>> q = fptr[a+1]; >>>> >>>> ////tunning test///////////////////////
LO_ph_acc+=LO_Ph_Inc;
>>>> >>>> if(LO_ph_acc> (2 * PI) ) >>>> LO_ph_acc-=(2 * PI); >>>> >>>> i*=cos(LO_ph_acc); // shift I/Q >>>from 8 khz to 0 Hz >>>> q*=sin(LO_ph_acc); // >>>> >>>> final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate >>>> } >>>> >>>> _____________________________ >>>> Posted through www.DSPRelated.com >>> >>>You are not doing a full complex downconversion. The nomenclature gets >>>confusing, but for j = sqrt(-1), your received value is a complex >>>number equal to >>> >>>x = i + j*q >>> >>>(note that my 'j' is not your index variable in the code above). You >>>want to multiply it by >>> >>>e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) >>> >>>Do the math, and you should (if I have my head on straight) get: >>> >>>fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); >>>fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); >>> >>>final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); >>> >>>Note that the C++ standard library has (if I remember correctly) a >>>complex data type that'll take care of the arithmetic for you, possibly >>>in a more efficient manner than you can hand-code it. >>> >>>-- >>> >>>Tim Wescott Wescott Design Services http://www.wescottdesign.com >>> >>> >>> >> Tim >> Thanks for answering my newbie type questions. I am moving in dsp by >> the help of people like you and trying to implement each block after >> understanding the concept and then seeing the result programmatically. >> I am now stuck in Digital Down conversion and even after googling >> unable to find: >> >> 1. Difference between half and full complex down conversion. >> >> 2. Which (complex down conversion) is suitable for Frequency >> translation or tuning given we have I/Q samples. >> >> 3.Which (complex down conversion) is suitable for Frequency translation >> or tuning given we have raw samples and we have to generate base band >> ((I/Q) for given frequency. >> >> 4. Any article with example psuedocode that can be translated in to >> software (source code). >> >> The code for down-conversion i adopted was from saqrx sdr files, if its >> not correct then i doubt how it works because it uses LO for 16500 hz >> for signals of interest and multiply signals from sound card ADC to >> this LO to generate I/Q samples. >> >> Thanks > > Hello, > > It appears to me that you are putting the hart before the corse. > > What I suggest is that you shut down your computer, get out a book (Rick > Lyons' "Understanding Digital Signal Processing" would be good), a > pencil, and some paper, and read about complex upconversion and > downconversion. Write out some simple examples by hand. Then I bet a few > lights will come on.
That's a good recommendation. I've made some comments in that direction that were both much snippier and much more obscure. I can't imagine going very far in DSP without starting from the math and going forward from there, although I suppose it could be done. I also suggest that when you _do_ fire up the computer and start playing again, that you install Scilab and use it to test out algorithms. Once you learn the shortcuts, Scilab makes a much better playground for verifying math with real-world data than C or C++. In case you're curious, my development methodology here is: 1: Develop the math on paper (Well, using LaTeX, but that's just paper with a much better way of erasing). I might use WxMaxima to help with the symbolic manipulation. 2: Prototype the math with Scilab. 3: If it needs to go that far, implement the math with C, C++, assembly, or whatever else works best for the problem at hand. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Tim Wescott <tim@seemywebsite.really> writes:

> On Fri, 27 Jun 2014 09:29:45 -0400, Randy Yates wrote: > >> "engrmasood2002" <100558@dsprelated> writes: >> >>>>On Thu, 26 Jun 2014 13:22:44 -0500, engrmasood2002 wrote: >>>> >>>>> Hi All An SDR Software (SDRSharp) plays the file containing two >>>>> stations one at 0hz and other at 8khz. By Clicking at both the >>>>> stations one by one (FFT Display) stations can be heard. >>>>> I tried to demodulate them in my software and always able to hear >>>>> station at 0Hz after demodulation. even i have shifted 8Khz signal to >>>>> 0Hz but i am able to hear only station that was initially at 0Hz. >>>>> Maybe i am doing something wrong. can any one tell me by looking at >>>>> the code what i am doing wrong >>>>> >>>>> float carrFrq=8000.0; //station to tune and to be shifted to 0Hz >>>>> float LO_Frq=carrFrq; >>>>> float LO_Ph_Inc= ( (2.0*PI*LO_Frq)/FS); >>>>> float LO_ph_acc=0; >>>>> >>>>> float LO_ph_acc=0; // NCO >>>>> for(int a=0; a<samples_count*2;a+=2) >>>>> { >>>>> i = fptr[a]; // fptr contains >>>>I/Q from wave file at 0Hz >>>>> q = fptr[a+1]; >>>>> >>>>> ////tunning test/////////////////////// > LO_ph_acc+=LO_Ph_Inc; >>>>> >>>>> if(LO_ph_acc> (2 * PI) ) >>>>> LO_ph_acc-=(2 * PI); >>>>> >>>>> i*=cos(LO_ph_acc); // shift I/Q >>>>from 8 khz to 0 Hz >>>>> q*=sin(LO_ph_acc); // >>>>> >>>>> final[j++]= 83 * sqrt( (i * i ) + (q * q) ); //demodulate >>>>> } >>>>> >>>>> _____________________________ >>>>> Posted through www.DSPRelated.com >>>> >>>>You are not doing a full complex downconversion. The nomenclature gets >>>>confusing, but for j = sqrt(-1), your received value is a complex >>>>number equal to >>>> >>>>x = i + j*q >>>> >>>>(note that my 'j' is not your index variable in the code above). You >>>>want to multiply it by >>>> >>>>e^(-LO_ph_acc) = cos(LO_ph_acc) - j * sin(LO_ph_acc) >>>> >>>>Do the math, and you should (if I have my head on straight) get: >>>> >>>>fi = i * cos(LO_ph_acc) + q * sin(LO_ph_acc); >>>>fq = q * cos(LO_ph_acc) - q * sin(LO_ph_acc); >>>> >>>>final[j++] = 83 * sqrt((fi * fi) + (fq * fq)); >>>> >>>>Note that the C++ standard library has (if I remember correctly) a >>>>complex data type that'll take care of the arithmetic for you, possibly >>>>in a more efficient manner than you can hand-code it. >>>> >>>>-- >>>> >>>>Tim Wescott Wescott Design Services http://www.wescottdesign.com >>>> >>>> >>>> >>> Tim >>> Thanks for answering my newbie type questions. I am moving in dsp by >>> the help of people like you and trying to implement each block after >>> understanding the concept and then seeing the result programmatically. >>> I am now stuck in Digital Down conversion and even after googling >>> unable to find: >>> >>> 1. Difference between half and full complex down conversion. >>> >>> 2. Which (complex down conversion) is suitable for Frequency >>> translation or tuning given we have I/Q samples. >>> >>> 3.Which (complex down conversion) is suitable for Frequency translation >>> or tuning given we have raw samples and we have to generate base band >>> ((I/Q) for given frequency. >>> >>> 4. Any article with example psuedocode that can be translated in to >>> software (source code). >>> >>> The code for down-conversion i adopted was from saqrx sdr files, if its >>> not correct then i doubt how it works because it uses LO for 16500 hz >>> for signals of interest and multiply signals from sound card ADC to >>> this LO to generate I/Q samples. >>> >>> Thanks >> >> Hello, >> >> It appears to me that you are putting the hart before the corse. >> >> What I suggest is that you shut down your computer, get out a book (Rick >> Lyons' "Understanding Digital Signal Processing" would be good), a >> pencil, and some paper, and read about complex upconversion and >> downconversion. Write out some simple examples by hand. Then I bet a few >> lights will come on. > > That's a good recommendation. I've made some comments in that direction > that were both much snippier and much more obscure. > > I can't imagine going very far in DSP without starting from the math and > going forward from there, although I suppose it could be done. > > I also suggest that when you _do_ fire up the computer and start playing > again, that you install Scilab and use it to test out algorithms. Once > you learn the shortcuts, Scilab makes a much better playground for > verifying math with real-world data than C or C++. > > In case you're curious, my development methodology here is: > > 1: Develop the math on paper (Well, using LaTeX, but that's just paper > with a much better way of erasing). I might use WxMaxima to help with > the symbolic manipulation. > > 2: Prototype the math with Scilab. > > 3: If it needs to go that far, implement the math with C, C++, assembly, > or whatever else works best for the problem at hand.
Agreed. (Someone else use's LaTeX? Cool!) -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Randy Yates <yates@digitalsignallabs.com> writes:
> [...] > (Someone else use's LaTeX? Cool!)
Sheesh, "use's" Randy? I don't know what's wrong with me; lately I've been hosing up my grammar! -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com