Channel estimation is not working at all.
Maybe a math problem with how I did things? Almost definitely
This commit is contained in:
parent
dbdf45ef05
commit
2b395b458a
15
channel.py
15
channel.py
@ -4,8 +4,8 @@ import scipy.interpolate
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
# Dirac delta function response, no change
|
# Dirac delta function response, no change
|
||||||
channel_response = np.array([0, 0, 0, 1, 0, 0, 0])
|
#channel_response = np.array([0, 0, 0, 1, 0, 0, 0])
|
||||||
#channel_response = np.array([-1 + 1j, 0, 1, 0.5, 0.25])
|
channel_response = np.array([1, 0, 0.3+0.3j])
|
||||||
|
|
||||||
|
|
||||||
# How do I sync this across two files?
|
# How do I sync this across two files?
|
||||||
@ -78,7 +78,7 @@ def estimate(in_data, pilots=0):
|
|||||||
print(pilot_carriers)
|
print(pilot_carriers)
|
||||||
|
|
||||||
# start averaging
|
# start averaging
|
||||||
H_est = 0
|
#H_est = 0
|
||||||
|
|
||||||
# for i in range(len(in_data)):
|
# for i in range(len(in_data)):
|
||||||
# # Obtain channel response at pilot carriers
|
# # Obtain channel response at pilot carriers
|
||||||
@ -98,6 +98,8 @@ def estimate(in_data, pilots=0):
|
|||||||
# Obtain channel response at pilot carriers
|
# Obtain channel response at pilot carriers
|
||||||
for i in pilot_carriers:
|
for i in pilot_carriers:
|
||||||
H_est_pilots[j] = in_data[0][i] / pilot_value
|
H_est_pilots[j] = in_data[0][i] / pilot_value
|
||||||
|
print("Value: " + str(in_data[0][i]))
|
||||||
|
print("Pilot estimate: " + str(H_est_pilots[j]))
|
||||||
j += 1
|
j += 1
|
||||||
|
|
||||||
|
|
||||||
@ -106,7 +108,7 @@ def estimate(in_data, pilots=0):
|
|||||||
H_est_phase = scipy.interpolate.interp1d(pilot_carriers, np.angle(H_est_pilots), kind='linear', fill_value='extrapolate')(all_carriers)
|
H_est_phase = scipy.interpolate.interp1d(pilot_carriers, np.angle(H_est_pilots), kind='linear', fill_value='extrapolate')(all_carriers)
|
||||||
|
|
||||||
# Take angular form and turn into rectangular form
|
# Take angular form and turn into rectangular form
|
||||||
H_est += H_est_abs * np.exp(1j*H_est_phase)
|
H_est = H_est_abs * np.exp(1j*H_est_phase)
|
||||||
|
|
||||||
# for an average channel estimate
|
# for an average channel estimate
|
||||||
# H_est = H_est / len(in_data)
|
# H_est = H_est / len(in_data)
|
||||||
@ -114,11 +116,6 @@ def estimate(in_data, pilots=0):
|
|||||||
# Exact channel response
|
# Exact channel response
|
||||||
H_exact = np.fft.fft(channel_response, len(in_data[0]))
|
H_exact = np.fft.fft(channel_response, len(in_data[0]))
|
||||||
|
|
||||||
for i in range(3):
|
|
||||||
plt.plot(abs(in_data[i]), "b")
|
|
||||||
plt.plot(np.abs(in_data[i]), "r")
|
|
||||||
plt.show(block=True)
|
|
||||||
|
|
||||||
plt.plot(all_carriers, np.real(H_exact), "b")
|
plt.plot(all_carriers, np.real(H_exact), "b")
|
||||||
plt.plot(all_carriers, np.real(H_est), "r")
|
plt.plot(all_carriers, np.real(H_est), "r")
|
||||||
plt.plot(pilot_carriers, np.real(H_est_pilots), "go")
|
plt.plot(pilot_carriers, np.real(H_est_pilots), "go")
|
||||||
|
15
main.py
15
main.py
@ -56,6 +56,15 @@ def cp_remove(in_data, prefix_len):
|
|||||||
return out_data
|
return out_data
|
||||||
|
|
||||||
|
|
||||||
|
def check_theoretical_channel(tx):
|
||||||
|
H_exact = np.fft.fft([1, 0, 0.3 + 0.3j], len(tx[0]))
|
||||||
|
|
||||||
|
rx = np.ndarray((len(tx[0])), dtype=np.csingle)
|
||||||
|
|
||||||
|
for i in range(len(tx[0])):
|
||||||
|
rx[i] = H_exact[i] * tx[0][i]
|
||||||
|
|
||||||
|
return rx
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -76,9 +85,15 @@ if __name__ == '__main__':
|
|||||||
# Add cyclic prefix to each symbol
|
# Add cyclic prefix to each symbol
|
||||||
tx = cp_add(ofdm_time, 16)
|
tx = cp_add(ofdm_time, 16)
|
||||||
|
|
||||||
|
theoretical_rx = check_theoretical_channel(tx)
|
||||||
|
|
||||||
# Simulate effects of a multipath channel
|
# Simulate effects of a multipath channel
|
||||||
rx = channel.sim(tx)
|
rx = channel.sim(tx)
|
||||||
|
|
||||||
|
plt.plot(rx[0], "b")
|
||||||
|
plt.plot(theoretical_rx, "r")
|
||||||
|
plt.show(block=True)
|
||||||
|
|
||||||
# Remove cyclic prefix from incoming symbols
|
# Remove cyclic prefix from incoming symbols
|
||||||
ofdm_cp_removed = cp_remove(rx, 16)
|
ofdm_cp_removed = cp_remove(rx, 16)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user