I-Q demod algorithm?

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2005
Posts: 3
Reputation: petethepop is an unknown quantity at this point 
Solved Threads: 0
petethepop petethepop is offline Offline
Newbie Poster

I-Q demod algorithm?

 
0
  #1
Jun 18th, 2005
I'm not a c-programmer, rather a guy who inherited a system that previously had an I/Q demodulation in a gate array, need to move it into c-code. I have 1024 sample buffer that was synchronously digitized with x4 clock, so samples are alternately +I, +Q, -I, -Q,....... Need a snippet of code that flips signs of alternate I's and Q's so they are all positive, then sums the I's and Q's. I know this is trivial for a c-programmer, but not so for a non-programmer. Can anyone point me to an example, please?
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,461
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 254
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: I-Q demod algorithm?

 
0
  #2
Jun 18th, 2005
How about using abs to get the absolute value? Perhaps post an attempt.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 3
Reputation: petethepop is an unknown quantity at this point 
Solved Threads: 0
petethepop petethepop is offline Offline
Newbie Poster

Re: I-Q demod algorithm?

 
0
  #3
Jun 18th, 2005
yes, thanks, abs gives 1024 samples of interleaved I and Q. Now I need the simple chunk of code that sums alternate samples to Isum and Qsum
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,461
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 254
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: I-Q demod algorithm?

 
0
  #4
Jun 18th, 2005
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   unsigned long Isum = 0, Qsum = 0;
   int buffer[1024];
   size_t i;
   /*
    * Fill the buffer with values between -100 and 100
    * (you can probably skip this).
    */
   srand(time(NULL));
   for ( i = 0; i < sizeof buffer / sizeof *buffer; ++i )
   {
      buffer[i] = rand() % 200 - 100;
   }
   /*
    * Calculate sums.
    */
   for ( i = 0; i < sizeof buffer / sizeof *buffer; ++i )
   {
      if ( i % 2 )  /* odd */
      {
         Qsum += abs(buffer[i]);
      }
      else          /* even */
      {
         Isum += abs(buffer[i]);
      }
   }
   printf("Isum = %lu, Qsum = %lu\n", Isum, Qsum);
   return 0;
}

/* my output
Isum = 26194, Qsum = 24823
*/
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 3
Reputation: petethepop is an unknown quantity at this point 
Solved Threads: 0
petethepop petethepop is offline Offline
Newbie Poster

Re: I-Q demod algorithm?

 
0
  #5
Jun 18th, 2005
Dave,

Good help. Many thanks. Will pass it on when I can.

Pete
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum


Views: 1449 | Replies: 4
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC