[英]Python using MCP3008 sample frequency
I am trying to make project of visible light communication.我正在尝试制作可见光通信项目。 Currently I am using a classic LED as TX part and BPW21 photodiode with MCP3008 AD convertor as a RX part.
目前,我使用经典 LED 作为 TX 部分,使用带有 MCP3008 AD 转换器的 BPW21 光电二极管作为 RX 部分。 Both of this part run on the RasPi4 withy python 3.7.3.
这两个部分都在带有 python 3.7.3 的 RasPi4 上运行。 However I have problem with receiving the bits using OOK modulation on RX part.
但是,我在 RX 部分使用 OOK 调制接收位时遇到问题。
import busio
import digitalio
import board
import time
import adafruit_mcp3xxx.mcp3008 as MCP
from adafruit_mcp3xxx.analog_in import AnalogIn
spi = busio.SPI(clock=board.SCK, MISO=board.MISO, MOSI=board.MOSI)
cs = digitalio.DigitalInOut(board.D5)
mcp = MCP.MCP3008(spi, cs)
channel_0 = AnalogIn(mcp, MCP.P0)
def evaluateSensorValue():
bits = ""
sensor_value = channel_0.value
channel_voltage = channel_0.voltage
if channel_voltage < 3.0:
bits = "1"
print("1")
else:
bits = "0"
print("0")
while True:
evaluateSensorValue()
time.sleep(0.05)
I am reading input from the Channel 0 of MCP3008.我正在从 MCP3008 的通道 0 读取输入。 However in such a low frequency of 20Hz, I am not able to "catch" all the bits.
然而,在如此低的 20Hz 频率下,我无法“捕捉”所有比特。 BPW21 has fast response time to light in 1.5 us fall and rise time.
BPW21 在 1.5 us 的下降和上升时间内具有快速的照明响应时间。 I thouht that MCP3008 will be fast enough to catch all the bits in frequency of 10 kHz, not only lower than 20 Hz.
我认为 MCP3008 将足够快以捕获 10 kHz 频率的所有位,而不仅仅是低于 20 Hz。 How can I make it way much faster on RX side to be able to receive data in higher frequencies?
如何在 RX 端更快地接收更高频率的数据? Thank you for any kind of help!
感谢您提供任何帮助!
This answer is solved.这个答案解决了。 The problem was in the very high sampling frequency of the AD converter.
问题在于 AD 转换器的采样频率非常高。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.