944,156 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1702
  • C RSS
Jun 18th, 2005
0

I-Q demod algorithm?

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
petethepop is offline Offline
3 posts
since Jun 2005
Jun 18th, 2005
0

Re: I-Q demod algorithm?

How about using abs to get the absolute value? Perhaps post an attempt.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Jun 18th, 2005
0

Re: I-Q demod algorithm?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
petethepop is offline Offline
3 posts
since Jun 2005
Jun 18th, 2005
0

Re: I-Q demod algorithm?

#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
*/
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Jun 18th, 2005
0

Re: I-Q demod algorithm?

Dave,

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

Pete
Reputation Points: 10
Solved Threads: 0
Newbie Poster
petethepop is offline Offline
3 posts
since Jun 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Winsock2.h and Platform SDK
Next Thread in C Forum Timeline: semaphores





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC