# implementation of a basic function of Code Division Multiple Access(CDMA) and to test the orthogonality and auto-correlation of code to be used for CDMA operation implementation of a basic function of Code Division Multiple Access(CDMA) and to test the orthogonality and auto-correlation of code to be used for CDMA operation.

What is CDMA?
1. CDMA stands for Code Division Multiple Access.
2. It is a digital cellular standard that utilizes spread-Spectrum Technology.
3. It spreads the signal over a fully available spectrum or over multiple channels through division.
4. It is a more secure and private line.
5. It has good voice and data communication capabilities.
6. The information is sent simultaneously through several transmitters over a single communication channel.
Procedure:

1.  The station encodes its data bit as follows.
If bit = 1 then +1
If bit = 0 then  -1

no signal(interpreted as 0) if station is idle

2.  Each station is allocated a different orthogonal sequence (code) which is N bit long for N stations

3.  Each station does a scalar multiplication of its encoded data bit and code sequence.

4.  The resulting sequence is then stored on the channel.

5.   Since the channel is common, amplitudes add up and hence resultant channel sequence is the sum of sequences from all channels.

6.  If station 1 wants to listen to station 2, it multiplies (inner product) the channel sequence with code of station S2.

7.  The inner product is then divided by N to get data bit transmitted from station 2.

Code:

import numpy as np
c1=[1,1,1,1]
c2=[1,-1,1,-1]
c3=[1,1,-1,-1]
c4=[1,-1,-1,1]
rc=[]

print("Enter the data bits :")

d1=int(input("Enter D1 :"))
d2=int(input("Enter D2 :"))
d3=int(input("Enter D3 :"))
d4=int(input("Enter D4 :"))
r1=np.multiply(c1,d1)
r2=np.multiply(c2,d2)
r3=np.multiply(c3,d3)
r4=np.multiply(c4,d4)
resultant_channel=r1+r2+r3+r4;
print("Resultant Channel",resultant_channel)
Channel=int(input("Enter  the station to listen for C1=1 ,C2=2, C3=3 C4=4 : "))

if Channel==1:
rc=c1
elif Channel==2:
rc=c2
elif Channel==3:
rc=c3
elif Channel==4:
rc=c4
inner_product=np.multiply(resultant_channel,rc)

print("Inner Product",inner_product)
res1=sum(inner_product)

data=res1/len(inner_product)
print("Data bit that was sent",data)