# How CDMA receiver extract it's corresponding data from the receiving modulated & superposition-ed signal?

I have difficulty understanding CDMA.

I have read all those PN/walsh code things, and understand orthogonality very well.

But none of the resources I found demonstrate how a receiver end extract data from modulated & superposition-ed signal.

Most of them just stop at the digital encoding & decoding part and skip the modulation part.

But in real implementation signals of different walsh code are modulated then superposition-ed.

I cannot figure out how it is done.

======================================================

P.S. I am confused that does the sender add the signals before or after modulation?

If before, take BPSK as an example, there is a chance there would be >2 different values in the added result vector, which can no longer be encoded in BPSK.

If after, then the signals are simply super-positioned, the receiver would often see both 0&1, with different amplitudes, at the same time, i.e. Acos(wt)+Bcos(wt+pi), which seems a bit hard to decode.

You clarified that your question really is how multiple users can be separated in code space. Since you said that you understand orthogonality well, I assume you just need an example to tie it all together.

With reference to the below examples of the DFT (OFDM) and Hadamard Matrices (CDMA) where each row of either represents a different orthogonal code that we can assign to a different user, channel or resource. For CDMA and with reference to the 8th order Hadamard Matrix, which I am referring to as $$H_8$$, we have a code set of 8 possible codes which we can use for multiple access with 8 different users by assigning each user a different code.

We can then choose a modulation to use for each symbol, for example BPSK, QPSK, QAM etc. BPSK is simplest so I will start with demonstrating that assuming one particular user that has the 2nd row as their code which is $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$:

For BPSK the users data such as 0 1 1 0 1 1 1 0 is mapped to symbols -1 and 1 (bi-phase 0 or 180°). To mix with the code we simply multiply each symbol with the code sequence for that user, so to send the data above we would do:

User Data: $$\begin{bmatrix}0 &1 &1 &0 &1 &1 &1 & 0\end{bmatrix}$$

Data Symbols: $$\begin{bmatrix}-1 &1 &1 &-1 &1 &1 &1 &-1\end{bmatrix}$$

Symbol 1: $$-H_{8,2} =\begin{bmatrix}-1 &1 &-1 &1 &- 1 &1 & -1 &1\end{bmatrix}$$

Symbol 2: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

Symbol 3: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

Symbol 4: $$-H_{8,2} =\begin{bmatrix}-1 &1 &-1 &1 &- 1 &1 & -1 &1\end{bmatrix}$$

Symbol 5: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

Symbol 6: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

Symbol 7: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

Symbol 8: $$-H_{8,2} =\begin{bmatrix}-1 &1 &-1 &1 &- 1 &1 & -1 &1\end{bmatrix}$$

Thus the users 7 data bits in this example was converted to 56 actual bi-phase symbols to be transmitted (in this case "spread spectrum" specifically since the data rate and hence the occupied bandwidth was increased). To receive the sequence for this user, we simply correlate (multiply and accumulate) the received sequence to each code and detect which one is strongest and what the magnitude and phase is to demodulate the underlying modulation.

Since the codes are orthogonal, you could encode a 2nd users data in all the same time slots, add the resulting encoded symbols and we would be able to separate the users in the receiver by correlating to each code in turn.

For example if we want to send a data bit 0 to User 1 who uses the 2nd row of $$H_2$$ as we did above:

$$-H_{8,2} =\begin{bmatrix}-1 &1 &-1 &1 &- 1 &1 & -1 &1\end{bmatrix}$$

And at the same time we send a data bit 1 User 2 who uses the 1st row of $$H_2$$:

$$H_{8,1} =\begin{bmatrix}1 &1 &1 &1 &1 &1 & 1 &1\end{bmatrix}$$

The combined result that we would transmit would be the addition of the two:

$$t = \begin{bmatrix}0 &2 &0 &2 &0 &2 & 0 &2\end{bmatrix}$$

In the receiver we can correlate to each user by taking the dot product (multiply and accumulate which is correlation) of the time aligned received sequence with each code:

$$t \cdot H_{8_1} = +8$$ The best estimate is +1 symbol was transmitted = data bit 1

$$t \cdot H_{8_2} = -8$$ The best estimate is a -1 symbol was transmitted = data bit -1

When we don't have time aligned in the receiver, we can use special acquisition sequences that have good autocorrelation properties for finding time offset. This also holds true when we can't guarantee time alignment between all the codes such as when the users are transmitting- Walsh codes are orthogonal when time aligned to each other, but do not have good cross correlation properties when there are time offsets between the codes.

If the modulation of choice was QPSK, then the users data would be mapped 2 bits at a time to 4 symbols, for example $$1 0 \rightarrow 1$$, $$1 1 \rightarrow j$$, $$0 1 \rightarrow -1$$ and $$0 0 \rightarrow -j$$ but the process would be exactly the same.

User Data: $$\begin{bmatrix}0 &1 &1 &0 &1 &1 &1 & 0\end{bmatrix}$$

Data Symbols: $$\begin{bmatrix}-1 &1 &j &1\end{bmatrix}$$

Symbol 1: $$-H_{8,2} =\begin{bmatrix}-1 &1 &-1 &1 &- 1 &1 & -1 &1\end{bmatrix}$$

Symbol 2: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

Symbol 3: $$jH_{8,2} =\begin{bmatrix}j &-j &j &-j &j &-j &j &-j\end{bmatrix}$$

Symbol 4: $$H_{8,2} =\begin{bmatrix}1 &-1 &1 &-1 &1 &-1 &1 &-1\end{bmatrix}$$

We can then multiply the resulting real or complex numbers from the coding above with a carrier frequency to translate the modulated signal to any frequency carrier of interest.

Everything involved to actually receive this properly is more complex due to adjusting for timing offset, frequency offset, phase ambiguity, channel distortion, phase noise, etc etc but that aspect is similar across all types of receivers. With regards to removing the code modulation we simply multiply again by the code once time aligned.

Observe the similarity between OFDM and CDMA in that the DFT is just another orthogonal code space. In the case of Walsh Codes we use two symbols such as 0 and 1, while in the case of the DFT we use the Nth roots of unity which are complex points equally distributed on the unit circle. Both allow us to transmit to multiple users (or multiple channels to one user) in the same time slot, in contrast to TDMA. The DFT is more intuitive since we are so used to visualizing different frequencies such that we see how they don't overlap, but the same thing occurs with Walsh codes it's just that we are in a different code space. With that in mind, compare carefully the 2, 4 and 8 point DFT matrices to Walsh code sets of the same order (Hadamard Matrices).

Often for Walsh Codes, Hadamard Matrices or order N are designated as $$W_N$$ but to avoid confusion with the DFT twiddle factors $$W_N^{nk}$$ I will use $$H_N$$ here as Hadamard Matrices:

2 Pt DFT Matrix

$$\begin{bmatrix}1& 1\\1 &-1 \end{bmatrix}$$

$$H_2 = \begin{bmatrix}1& 1\\1 &-1 \end{bmatrix}$$

4 Pt DFT Matrix

$$\begin{bmatrix}1& 1 & 1 & 1\\1 & -j & -1 & j \\1& -1 & 1 & -1\\1 & j & -1 & j \end{bmatrix}$$

$$H_4 =\begin{bmatrix} H_2 & H_2 \\ H_2 & -H_2\end{bmatrix} = \begin{bmatrix}1& 1 & 1 & 1\\1 &-1 & 1 & -1 \\1& 1 & -1 & -1\\1 &-1 & -1 & 1 \end{bmatrix}$$

8 Pt DFT Matrix

$$\begin{bmatrix}1& 1 & 1 & 1 & 1& 1 & 1 & 1\\1 & W_8^1 & W_8^2 & W_8^3 & -1 & -W_8^1 & -W_8^2 & -W_8^3\\1 & W_8^2 & -1 & -W_8^2 & 1 & W_8^2 & -1 & -W_8^2\\1 & W_8^3 & -W_8^2 & W_8^1 & -1 & -W_8^3 & W_8^2 & -W_8^1 \\1& -1 & 1 & -1 & 1& -1 & 1 & -1\\1 & -W_8^1 & W_8^2 & -W_8^3 & -1 & W_8^1 & -W_8^2 & W_8^3\\1 & -W_8^2 & -1 & W_8^2 & 1 & -W_8^2 & -1 & W_8^2\\1 & -W_8^3 & -W_8^2 & -W_8^1 & -1 & W_8^3 & W_8^2 & W_8^1 \end{bmatrix}$$

$$H_8 =\begin{bmatrix} H_4 & H_4 \\ H_4 & -H_4\end{bmatrix} =\begin{bmatrix} 1& 1 & 1 & 1 &1& 1 & 1 & 1\\ 1 &-1 & 1 & -1 &1 &-1 & 1 & -1 \\ 1& 1 & -1 & -1 &1& 1 & -1 & -1\\ 1 &-1 & -1 & 1 & 1 &-1 & -1 &1 \\ 1& 1 & 1 & 1 &-1& -1 & -1 & -1\\ 1 &-1 & 1 & -1 &-1 &1 & -1 & 1 \\ 1& 1 & -1 & -1 &-1& -1 & 1 & 1\\ 1 &-1 & -1 & 1 & -1 &1 & 1 &-1\end{bmatrix}$$

Where in the 8pt DFT matrix, $$W_N^{n} = e^{-j2\pi n/N}$$

We tend to give a more physical preeminence to the concept of frequency separation as if that is more representative of the real world than code separation, and think of code separation as just a mathematical construct. They are both equivalently mathematical constructs and both will result in waveforms that will occupy the same spectral bandwidth as a transmitted signal (and there we have decided to use frequency space to share our use of the ether overall). Step back for a moment and ignore all your training and experience with sine waves and observe what is happening above and how similar they are, and how they both have the same level of physical meaning if you are trying to associate it with one. This is similar to the unfortunate naming of "real" and "imaginary" numbers--- one is no more "real" than the other! I have had people tell me that they believe complex numbers don't actually exist like real numbers do- you can observe a real number in the lab with a scope probe--- well you can observe a complex number in the lab with two scope probes! It is all equivalently math that we use to describe our physical world.

My prior answer before the question was clarified which I will retain since it is related:

I don't think your question is specific to CDMA but more in general what does mixing and modulating mean. What I am about to say is applicable to CDMA but also to any receiver that extracts data from a "mixed and modulated" signal.

Modulation is specifically the process of mapping data to a symbol for transmission, for example BPSK, QSPK, QAM, FSK, MSK, etc are all modulations. For one of the simplest, BPSK, we map data bits from 0 to 1 to phases of the carrier 0° and 180°.

Mixing usually refers to the process of translating a signal from one frequency to another using time domain multiplication (devices that do this in the analog domain are called "mixers", but we can also do this in the digital domain but typically refer to them simply as multipliers - they are doing the same thing).

To keep this simple I am not going to get into complex signals but will show the process of modulating and mixing a BPSK signal.

Data = 0 1 0 1 1

BPSK Modulation : -1 +1 -1 +1 +1

Multiply with a carrier frequency ($$\omega_c$$):

To send =1: $$(-1)\cos(\omega t)$$

To send +1: $$(+1)\cos(\omega t)$$

To demodulate multiply with local oscillator with frequency ($$\omega_c$$) that has been locked the carrier using a carrier recovery loop:

If receiving a =1:

$$(-1)\cos(\omega t)\cos(\omega t) = \frac{(-1)}{2}\cos(2\omega t)+\frac{(-1)}{2}\cos(0)$$

Filter out the high frequency component to get $$-\frac{1}{2}$$ This maps to the 0 bit received.

If receiving a +1:

$$(+1)\cos(\omega t)\cos(\omega t) = \frac{(+1)}{2}\cos(2\omega t)+\frac{(+1)}{2}\cos(0)$$

Filter out the high frequency component to get $$\frac{1}{2}$$ This maps to the 1 bit received.

• sorry, what I mean by mixing is when multiple signal of the same band/channel but different walsh code superposition-ed. I don't understand how can a receiver extract the correct data in such case. I understand FDMA & TDMA, but not CDMA. – somebody4 Jan 23 at 8:13
• Sorry, didn't notice it was updated. And Thanks for the incredibly detailed answer. But I am confused that does the sender add the signals before or after modulation? If before, take BPSK as an example, there is a chance there would be >2 different values in the added result vector. If after, then the signals are simply super-positioned, the receiver would often see both 0&1, with different amplitudes, at the same time. – somebody4 Feb 2 at 12:34
• The CDMA part can be considered simply a data encoding —- you start with data, you “spread” the data with the CDMA code by replacing each data bit with the full sequence and you end up with new “data” in that it is still just 1’s and 0’s. You can then modulate this any way you choose (BPSK QPSK etc). If transmitting to multiple users you modulate each and then sum and the composite signal is simply frequency translated to the carrier frequency by multiplying it with the carrier. Does that answer your question? – Dan Boschen Feb 2 at 12:38
• Sorry I still don't understand how [0 2 0 2 0 2 0 2] arise. – somebody4 Feb 2 at 12:50
• If addition is after modulation, with 3 users & BPSK, the signal would be like [cos(wt)+2cos(wt+pi), 2cos(wt)+cos(wt+pi), 3cos(wt+pi) ...], I don't know how it can be decoded – somebody4 Feb 2 at 12:56