Issue
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. Both of this part run on the RasPi4 withy python 3.7.3. However I have problem with receiving the bits using OOK modulation on RX part.
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. However in such a low frequency of 20Hz, I am not able to "catch" all the bits. BPW21 has fast response time to light in 1.5 us fall and rise time. I thouht that MCP3008 will be fast enough to catch all the bits in frequency of 10 kHz, not only lower than 20 Hz. How can I make it way much faster on RX side to be able to receive data in higher frequencies? Thank you for any kind of help!
Solution
This answer is solved! The problem was in the very high sampling frequency of the AD converter.
Answered By - dejv_IT