1
$\begingroup$

The task is to implement communication system for transmission of 32 multiplexed signals through communication channel represented by copper cable whose frequency characteristic is given by:

$$H(f) = e^{-d\gamma(f)}$$

$$\gamma(f) = j 2\pi f \sqrt{LC \left (1+ \frac{(1-j)k}{L\sqrt{2\pi f}}\right)}$$

where: $d$=1200m, $L$= 0.5 mH / km, $C$=0.04 µF/km, $k$=0.18.

Amplitude characteristic of a communication channel should be analyzed in a frequency range from 0 to 500 kHz.

For the first part of my task, I should plot amplitude characteristic of transfer function in dB and impulse response of a communication channel.

The task should be done in Python.

Professor gave us what he got as plots and I think I should get the same plots as he did.

The plots he got:

enter image description here

The plots I get:

enter image description here

This is the code I used


import numpy as np
import matplotlib.pyplot as plt

# Given parameters
L = 0.5 * 1e-6  # H/m
C = 0.04 * 1e-9  # F/m
d = 1200  # meters
k = 0.18

# Frequency range from 0 to 500 kHz
frequency_range = np.linspace(0.1, 500.1, 500_000)

# Transfer function y(f)
y = 1j * 2 * np.pi * frequency_range * np.sqrt((L * C) * (1 + ((1 - 1j) * k) / (L * np.sqrt(2 * np.pi * frequency_range))))

# Frequency response H(f)
H = np.exp(-d * y)

# Amplitude response
amplitude = np.abs(H)

# Convert to decibels
amplitude_dB = 20 * np.log10(amplitude)

# Impulse response using the inverse Fourier transform
h = np.fft.ifft(H)

# Time array for plotting impulse response
t1 = np.linspace(0.1, 50.1, 500_000)


# Create subplots side by side with switched positions
fig, axs = plt.subplots(1, 2, figsize=(15, 6))

# Plot amplitude response in dB
axs[0].plot(frequency_range, amplitude_dB)
axs[0].set_title('Channel Amplitude Response in dB')
axs[0].set_xlabel('Frequency (kHz)')
axs[0].set_ylabel('Amplitude (dB)')
axs[0].grid(True)

# Plot impulse response
axs[1].plot(t1, np.real(h))
axs[1].set_title('Impulse Response')
axs[1].set_xlabel('t (μs)')
axs[1].set_ylabel('h (t) ')
axs[1].grid(True)


plt.tight_layout()

plt.show()

As you can see the first plot is similar but the values on y axis are different and second plot is not even similar.


Do I need to convert the given units to base units as I did in my code, and if I do , will the coefficient 'k' change?
Does anyone know what could I do to get same plots as he does or If someone can spot a mistake in my code if there is one.

$\endgroup$
2
  • 1
    $\begingroup$ The formula seems wrong. The units don't pan out. Expressions like $\sqrt{2\pi f}$ are nonsense. The argument to the root has units of $Hz$ and you can't take the root of a $Hz$ $\endgroup$
    – Hilmar
    Commented Dec 1, 2023 at 21:45
  • 1
    $\begingroup$ Frankly, I would ask the professor for clarification. The equation as written is non-sensical and it's plainly wrong. $\endgroup$
    – Hilmar
    Commented Dec 2, 2023 at 17:11

1 Answer 1

0
$\begingroup$

There's something off with the units. $LC$ has unit $\left[s^2\right]$, so the square root has unit $\left[s^2 + F\sqrt{s}\right]$ which doesn't make sense.

In any case, once that's fixed, use standard units:

# Given parameters
L = 0.5 * 1e-3  # H/km
C = 0.04 * 1e-6  # F/km
d = 1.2  # km
k = 0.18

# Frequency range from 0 to 500 kHz
fmax = 500*1e3
step = 1000
frequency_range = np.linspace(1, fmax, step)

Then fix your time vector:

# Time array for plotting impulse response
fs = 2*fmax
t1 = np.linspace(0, step/fs*1e6, step)
$\endgroup$
2
  • $\begingroup$ Thanks, this helped. Can you explain me why did you use fs=2*fmax and why did you use step/fs*1e6 Really greatful for your help $\endgroup$
    – 3d014
    Commented Dec 1, 2023 at 22:43
  • $\begingroup$ The sampling frequency should be at least twice the max frequency, and for the time vector that’s one of the ways it can be constructed based on the length of $H$. The 1e6 is to have it in $\mu_s$. $\endgroup$
    – Jdip
    Commented Dec 2, 2023 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.