简体   繁体   English

有没有办法使用 python 发送和接收调制信号的信号?

[英]Is there a way of sending and receiving signals for modulated signal's using python?

Ive been trying to find ways of sending modulated signals on python which then later down the line do analyses on the data sent and received.我一直在尝试寻找在 python 上发送调制信号的方法,然后在稍后对发送和接收的数据进行分析。

At the moment i just want to be able to send data using a modulation format such as PAM and then receive it目前我只想能够使用诸如 PAM 之类的调制格式发送数据然后接收它

Any help would be appreciated thank you任何帮助将不胜感激谢谢

I haven't tried it, but there is a Komm Python library for analysis and simulation of communication systems.我没试过,但是有一个Komm Python 库用于通信系统的分析和仿真。 Komm includes an implementation of pulse-amplitude modulation komm.PAModulation , among other modulation schemes. Komm 包括脉冲幅度调制komm.PAModulation的实现,以及其他调制方案。

The komm.PAModulation class has a .modulate() method that takes data bits as input and modulates it to a transmit signal. komm.PAModulation class 有一个.modulate()方法,它将数据位作为输入并将其调制为传输信号。 And conversely, there is a .demodulate() method that takes a received signal the tries to demodulate data from it.相反,有一个.demodulate()方法接收接收到的信号并尝试从中解调数据。 It doesn't look like Komm comes with interfaces for radios or other modalities, so you'll need to figure out separately how to actually send and receive these signals.它看起来不像 Komm 带有无线电或其他模式的接口,所以你需要单独弄清楚如何实际发送和接收这些信号。

There is a way of sending signals in simulations.有一种在模拟中发送信号的方法。 Eg if you want to transmit the bit combination 10 in a 4QAM system, you would have to start with a modulator, which maps this to a complex symbol: Lets say the mapping is 1+1j -> Now you would have to "transmit" this complex symbol over a channel which introduces distortion (eg additive white gaussian noise).例如,如果您想在 4QAM 系统中传输位组合 10,则必须从调制器开始,它将其映射到一个复杂的符号:假设映射是 1+1j -> 现在您必须“传输”通道上的这个复杂符号会引入失真(例如加性高斯白噪声)。 At the receiver you now try to detect this symbol and map it back to the original 10 bit combination.在接收器上,您现在尝试检测此符号并将 map 恢复为原始 10 位组合。

I would recommend you to program this from scratch to get a better understanding of the topic.我建议您从头开始编程,以更好地理解该主题。

As a reference, I put this video here, which includes python code of 4QAM and BPSK simulations for AWGN: https://youtu.be/Q9ox769NEN4作为参考,我把这段视频放在这里,其中包括 4QAM 的 python 代码和 AWGN 的 BPSK 模拟: https://youtu.be/Q9ox769NEN4

There is a way of sending signals in simulations.有一种在模拟中发送信号的方法。 Eg if you want to transmit the bit combination 10 in a 4QAM system, you would have to start with a modulator, which maps this to a complex symbol: Lets say the mapping is 1+1j -> Now you would have to "transmit" this complex symbol over a channel which introduces distortion (eg additive white gaussian noise).例如,如果你想在 4QAM 系统中传输位组合10 ,你必须从一个调制器开始,它将这个映射到一个复杂的符号:假设映射是1+1j -> 现在你必须“传输”信道上的这种复杂符号会引入失真(例如加性高斯白噪声)。 At the receiver you now try to detect this symbol and map it back to the original 10 bit combination.在接收器处,您现在尝试检测此符号并将 map 恢复为原始的 10 位组合。

I would recommend you to program this from scratch to get a better understanding of the topic.我建议您从头开始对此进行编程,以更好地理解该主题。

The code for a 4QAM Modulation could eg look like this: 4QAM 调制的代码可能如下所示:

import matplotlib.pyplot as plt
import numpy as np
import pylab as pyl

def modulate_4QAM(bits):
    b_temp = np.reshape(bits * 2 - 1, (-1, 2)) # reshape bits in [0,1] to [-1,1]
    x = 1 / np.sqrt(2) * (b_temp[:, 0] + 1j * b_temp[:, 1])
    return x

def detecting_4QAM(received_signal):
    # detecting (slicing) and de-mapping
    received_bits = np.zeros((len(received_signal), 2))
    received_bits[:, 0] = np.real(received_signal) > 0
    received_bits[:, 1] = np.imag(received_signal) > 0
    received_bits = np.reshape(received_bits, (-1,))
    return received_bits

if __name__ == '__main__':
    b = pyl.randint(0, 2, int(4)) # generate random bits
    x = modulate_4QAM(b) # map bits to complex symbols
    noisePower=10**(-5/20) #caltulcate the noise power for a given SNR value
    noise = (noisePower)*1/np.sqrt(2)*(pyl.randn(len(x))+1j*pyl.randn(len(x)))#generate noise
    y_AWGN =x+noise # add the noise to the signal
    b_received = detecting_4QAM(y_AWGN)

Note that scaling from a 4QAM to a 64QAM would result in an additional programming/typing overhead and toolboxes become very handy for that.请注意,从 4QAM 扩展到 64QAM 会导致额外的编程/输入开销,工具箱对此非常方便。

This is only a fraction of a coding example which simulates the BER over SNR of an AWGN with a 4QAM modulation from: https://github.com/TheWirelessClassroom/PythonExamples/tree/Modulation这只是一个编码示例的一小部分,该示例模拟具有 4QAM 调制的 AWGN 的 BER 与 SNR,来自: https:https://github.com/TheWirelessClassroom/PythonExamples/tree/Modulation

PS I'm new to the forum and unsure if only the fraction or the full code is more helpful/wanted.附注:我是论坛的新手,不确定是部分代码还是完整代码更有帮助/需要。 I would be happy to get some feedback on that and change the post accordingly.我很乐意就此获得一些反馈并相应地更改帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM