| | |
I-Q demod algorithm?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2005
Posts: 3
Reputation:
Solved Threads: 0
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?
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
#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
![]() |
Similar Threads
- round robin algorithm (Computer Science)
- Round Robin Algorithm Simulation (C++)
- Eigenface Algorithm (Computer Science)
- Algorithm for checking contiguous blocks (C)
Other Threads in the C Forum
- Previous Thread: Winsock2.h and Platform SDK
- Next Thread: semaphores
Views: 1449 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory drawing dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable voidmain() wab win32 windows.h






