Forum Discussion
23 Replies
- Altera_Forum
Honored Contributor
--- Quote Start --- I am trying to synchronize the transmitted signal with the receiver by energy detection. The transmitted signal is a sine wave and I plan to autocorrelate it to obtain the peak and then transmitting the data. Could you please help me in implementing the autocorrelation using Stratix II. --- Quote End --- If the transmitted signal is a sinusoid, then the autocorrelation is a cosine. Auto-correlation not help you synchronize, cross-correlation does; you correlate a reference signal to the incoming signal and try to 'find' the start of the transmitted signal. Since the peaks of the cross-correlation of two sinusoids repeat every period, the synchronization is ambiguous, so it won't work very well. Synchronization based on autocorrelation typically uses pseudo-random binary sequences (PRBS), since the auto-correlation, or really the cross-correlation of a PRBS at the receiver, with the incoming PRBS has a peak. When you move the peak to the zeroth lag, you are synchronized to the transmitter. Radar and sonar systems use FM chirp pulses (linear FM), Barker codes, and other signals with sharp autocorrelation peaks. There is no peak in your scheme, so it won't work. Why don't you explain what you are trying to do. Can you change the transmit signal? Cheers, Dave - Altera_Forum
Honored Contributor
thanks for the reply Dave.I really appreciate your interest.
I am basically using OFDM kinda thing for Spatial Modulation. I am transmitting a sinusoid of say freq f1 for synchronization and subsequently of freq f2 for data and will be performing correlation with sinusoid of freq f1 on the receiver side. I expect to get a peak of approx 1 for auto-correlation which will trigger my receiver to collect data. The problem I have is that I am using 128 data length for each symbol and I am using altera blockset (simulink) and I am totally confused about what blocks to use for performing the correlation thing. thanks... - Altera_Forum
Honored Contributor
--- Quote Start --- I am basically using OFDM kinda thing for Spatial Modulation. I am transmitting a sinusoid of say freq f1 for synchronization and subsequently of freq f2 for data and will be performing correlation with sinusoid of freq f1 on the receiver side. I expect to get a peak of approx 1 for auto-correlation which will trigger my receiver to collect data. The problem I have is that I am using 128 data length for each symbol and I am using altera blockset (simulink) and I am totally confused about what blocks to use for performing the correlation thing. --- Quote End --- In direct spread spectrum (DSS) systems like CDMA, base stations transmit PRBS codes for synchronization. I have not looked into OFDM, so I am not familiar with their technique. However, your description does not sound correct, perhaps you really mean different 'carriers' for modulated data. Can you please provide a reference for OFDM where they discuss synchronization. Altera has some application notes on OFDM, so how do they synchronize? Cheers, Dave - Altera_Forum
Honored Contributor
I might have confused you by all that description. For now, lets just forget the other things(OFDM,SM and all). I will mention my exact problem.
I am generating a sine wave using a LUT with 128 sample points x1=round(((2^10)-1)*(1+sin(linspace(0,2*pi,128)))); now I need to perform w=xcorr(x1,x1,'coeff'); through the blocks in altera DSP Builder Blockset. - Altera_Forum
Honored Contributor
--- Quote Start --- I might have confused you by all that description. For now, lets just forget the other things(OFDM,SM and all). I will mention my exact problem. I am generating a sine wave using a LUT with 128 sample points x1=round(((2^10)-1)*(1+sin(linspace(0,2*pi,128)))); now I need to perform w=xcorr(x1,x1,'coeff'); through the blocks in altera DSP Builder Blockset. --- Quote End --- I'm not sure how to do this using specific blockset components, however, the two mathematical techniques are autocorrelation in the lag domain, and multiplication in the frequency domain. For autocorrelation in the lag domain, you multiply samples delayed by registers, eg., see this document (p11 has a hardware implementation) http://www.ovro.caltech.edu/~dwh/wbsddc/correlator_efficiency.pdf (http://www.ovro.caltech.edu/%7edwh/wbsddc/correlator_efficiency.pdf) For autocorrelation in the frequency domain, you can use an FFT, and take the magnitude squared of the output frequency channels. Cheers, Dave - Altera_Forum
Honored Contributor
You can use FIR compiler setting coefficients to your sine data(128 data as is or flipped). Correlation is sum of products just like filter's computation.
Edit: You will need just one cycle of f1 and its frequency must be equal to input f then you get max aoutput amplitude if f detected - Altera_Forum
Honored Contributor
Hey Kaz, thanks a lot for the idea. Should I need to use serial or parallel fir? I think serial would do the correlation but my input is 12-bit and thus I will be wasting 13 clock cycles for every output. could you please suggest a smarter configuration which I could use? I am using Stratix II device.
Just for the sake of understanding, could you please suggest me the configuration(coefficients and other settings) for completing the autocorrelation for a=[1 2 3 4]. Thanks a lot.... - Altera_Forum
Honored Contributor
Hi Saket,
The title of your post indicates that you want an autocorrelation. However, the FIR filtering option Kaz suggested (nice suggestion!) is effectively a cross-correlation; the filter coefficients are a sinusoid with the same frequency as the transmitted signal. If you 'filter' an incoming signal with this filter, then you will get peaks where the two signals are in phase, and zeroes where they are out of phase (if the filter length is only one period, then you only get one peak). Basically, you get the autocorrelation you are looking for with a different scaling, and a shift of the zeroth lag. You need to figure out what it is you really want first; auto- or cross-correlation. What parameter are you trying to determine? If you are simply looking for a power detection or system gain response, then an autocorrelation is sufficient. If you want timing information (delay or phase), then you need a cross-correlation. You then need to determine how unambiguous you need that time estimate, eg., a sinusoid is ambiguous every period (you can shift the received signal by a full period, and you will get the same cross-correlation result). Cheers, Dave - Altera_Forum
Honored Contributor
I want cross-correlation. I was trying to understand the process through FIR Megacore in Altera DSP, thats why I said to auto-correlate as once if I am able to auto-correlate through FIR megacore, them I am sure that I will be able to perform cross-correlation too. So I need help in parameterizing the FIR Megacore.
thanks a lot - Altera_Forum
Honored Contributor
--- Quote Start --- I want cross-correlation. --- Quote End --- Ok. --- Quote Start --- So I need help in parameterizing the FIR Megacore. --- Quote End --- When you 'correlate' your input signal with a sinusoid, you're performing an operation that is very similar to what you do when you perform a discrete Fourier transform (DFT). The following may give you a better understanding of what you are doing ... The Forward DFT equation is X[k] = sum_{n=0}^{n=N-1} x[n] * exp(-2*pi*k*n/N) Where the exponential can be split into cos and sine, or real and imaginary components, i.e., assuming x[n] are real-valued samples, then X_real[k] = sum_{n=0}^{n=N-1} x[n] * cos(2*pi*k*n/N) X_imag[k] = -sum_{n=0}^{n=N-1} x[n] * sin(2*pi*k*n/N) These equations implement the sum of N input samples x[n] multiplied by N weights; now what does that sound like? A FIR filter perhaps? There are two sets of FIR filter coefficients; one filter is a cosine filter, the other is a sine filter. The output of the filter is related to the magnitude and phase of the Fourier response at channel k. Where, in your case, k is the frequency of your sinusoid normalized by the sampling rate, i.e., k = f0/fs. Note that the above equation is the calculation at a single output sample time instant, so there is a parameter missing (your output sample time index), which is why the above equation doesn't look exactly like a FIR filter equation (the parameter k is fixed, since you're only measuring at one frequency). Cheers, Dave